小编Nat*_*anK的帖子

Powershell Multiple StartsWith子句

我正在从'713','714'等开头的文件中删除行.我现在这样做:

$stripped = $stripped | where{-Not $_.StartsWith('713')}
$stripped = $stripped | where{-Not $_.StartsWith('714')}
$stripped = $stripped | where{-Not $_.StartsWith('715')}
$stripped = $stripped | where{-Not $_.StartsWith('716')}
$stripped = $stripped | where{-Not $_.StartsWith('717')}
Run Code Online (Sandbox Code Playgroud)

这感觉超级邋.. 我该如何改进这段代码?

powershell powershell-4.0

2
推荐指数
1
解决办法
2326
查看次数

用空格替换前导零

我有一个多个记录的文本文件.每个记录都有一个字段,其中包含一些前导零,我需要用这些空格替换.记录将如下所示:

A206   000001204   X4609
Run Code Online (Sandbox Code Playgroud)

我需要记录看起来像这样:

A206        1204   X4609
Run Code Online (Sandbox Code Playgroud)

我对正则表达式非常不熟悉,但以下正则表达式似乎找到了我需要的匹配项:

\b0+
Run Code Online (Sandbox Code Playgroud)

但是,我不知道如何更换.NoteA ++的ReplaceAll会很棒但我也可以根据需要用C#,Powershell或Python创建一个快速程序.任何人都可以给我一些关于正则表达式的指针吗?

c# python regex powershell notepad++

-3
推荐指数
1
解决办法
957
查看次数

标签 统计

powershell ×2

c# ×1

notepad++ ×1

powershell-4.0 ×1

python ×1

regex ×1