2016-10-28 6 views
1

ソース制御ファイル(1000秒)ですべてのSQL Serverオブジェクト名(約800)を検索しようとしています。Select-String 1つの文字列を検索しますが、一致する行のファイルの処理を停止します。ここに私が得ているものの小さなサンプルがあります。それは 'was'の一致も返すべきです。PowerShellでテキストファイルの同じ行に複数の文字列を検索するSelect-String

Use the Select-String cmdlet to process both of the words 'test' and 'was' in the same sentence and all it returns is the matches for 'test'. 

('This is a test. How was your test?' | Select-String -Pattern @('test','was') -AllMatches).Matches 

Groups : {0} 
Success : True 
Name  : 0 
Captures : {0} 
Index : 10 
Length : 4 
Value : test 

Groups : {0} 
Success : True 
Name  : 0 
Captures : {0} 
Index : 29 
Length : 4 
Value : test 
あなたは、文字列の配列の代わりに正規表現を使用することによって、これを達成することができ

答えて

1

('This is a test. How was your test?' | Select-String -Pattern '\btest\b|\bwas\b' -AllMatches).Matches 
関連する問題