我正在编写一个代码,以便它找到具有 $control 但应该删除第一列以 * 开头的行
我正在与以下人员合作,但似乎不起作用..
$result = Get-Content $file.fullName | Select-String $control | Select-String -pattern "\^*" -notmatch
提前致谢
最佳答案
你在逃避错误的角色。你不想逃^
因为那是你“开始于”的 anchor 。你会想逃避星号,所以试试这个:
$result = Get-Content $file.fullName | Select-String $control | select-string -pattern "^\*" -notmatch
另外,如果你想要的只是线条,你也可以使用这个:
Get-Content $file.fullName | ? { $_ -match $control -and $_ -notmatch '^\*'}
关于regex - 在 powershell 选择字符串输出中删除以 *(asterisk) 开头的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17000330/