我想在test
变量中获取$channel
单词的总数,但是$a
返回的内容与$channel
相同。
$channel = "test1 test2 test3 test4 testIgnore1 testIgnore2 testIgnore3"
$a = Select-String -InputObject $channel -Pattern "test"
此处的确切解决方案是什么?
最佳答案
$channel = "test1 test2 test3 test4 testIgnore1 testIgnore2 testIgnore3"
([regex]::Matches($channel, "test" )).count
将为您提供比赛的次数:
7
关于powershell - 从变量获取匹配的字数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43182567/