返回的值不以&结尾的地方?

use*_*164 0 powershell

有没有办法添加一个where子句,使返回的值不以&?结尾?

$Test = Get-Content $List | Where ??? Does not end with a &
Run Code Online (Sandbox Code Playgroud)

Ans*_*ers 6

有几种检查方法(按性能从高到低排序):

  • ... | Where-Object { -not $_.EndsWith('&') }
  • ... | Where-Object { $_ -notlike '*&' }
  • ... | Where-Object { $_ -notmatch '&$' }