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