在powershell select-string输出中删除以*(asterik)开头的行

Pow*_*hel 2 regex powershell

我正在编写一个代码,以便找到具有$ control的行,但是应该删除以第一列*开头的行

我正在使用以下但似乎没有工作..

  $result = Get-Content $file.fullName | Select-String $control | Select-String -pattern "\^*" -notmatch
Run Code Online (Sandbox Code Playgroud)

提前致谢

Fro*_* F. 5

你正在逃避错误的角色.你不想逃避,^因为那是你"开始"的锚.你想要逃避星号,所以试试这个:

$result = Get-Content $file.fullName | Select-String $control | select-string -pattern "^\*" -notmatch
Run Code Online (Sandbox Code Playgroud)

此外,如果你想要的只是线条,你也可以使用:

Get-Content $file.fullName | ? { $_ -match $control -and $_ -notmatch '^\*'}
Run Code Online (Sandbox Code Playgroud)