2016-10-28 3 views
1

소스 제어 파일 (1000 's)에서 모든 SQL Server 개체 이름 (약 800)을 찾으려고합니다. Select-String 그것은 하나의 문자열을 발견 할 것이지만 일치하는 것을 발견 한 행에서 파일 처리를 중단합니다. 다음은 제가 얻은 것의 작은 샘플입니다. '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