0
我想根據一些XML文件的單詞列表做一些模式匹配。Powershell選擇字符串列表多個匹配
我有以下幾點:
$Result = Get-ChildItem -Recurse $FullPath\*.xml |
Select-String -Pattern $WordList |
Select-Object Path, Pattern, Line, LineNumber
當有在同一行的代碼多個匹配出現我的問題,
例如,如果$單詞表=「AA」,「AACC」,並該行是:
"This is a test line AA, BB, AACC, KK"
$ Result將僅基於第一個單詞(AA)的單行匹配。但是它不會給我所有三項結果,一項是基於「AA」的兩場比賽,另一項是「AACC」的比賽,全部都在同一行。
當前$結果:
Path Pattern Line LineNumber
** AA This is a test line AA, BB, AACC, KK 12
理想$結果:
Path Pattern Line LineNumber
** AA This is a test line AA, BB, AACC, KK 12
** AA This is a test line AA, BB, AACC, KK 12
** AACC This is a test line AA, AABB, AACC, KK 12