
다음 정규식을 사용하려고 합니다.
(?<=----Old-------\n)(((.+\n)+)\n*?)(?=__________________________________________)
여러 줄의 단어를 얻으려면
----Old-------
250096 - LT Security Role: Read Only, 250032 - Sales VIC3, 250083 -
Security Role: Base Security Role, 250080 - Security Role: Payment
Allocation, 250058 - Security Role: TFM Sales Consultant, 250103 - Web
Fleet SuperUser
그러나 선택 문자열은 아무것도 반환하지 않습니다.
나는 사용했다https://regex101.com/그리고https://www.regexpal.com/정규식은 예상대로 작동합니다.
도와주실 수 있나요?
$ModifyOldRegex = "(?<=----Old-------\n)(((.+\n)+)\n*?)(?=__________________________________________)"
$Description | Select-String -Pattern $ModifyOldRegex.matches.Value
답변1
마침내 문제를 발견했습니다.
1- \n이 작동하려면 get-Content -Raw를 사용하세요. // 이유가 확실하지 않습니다.
2- 정규식을 다음으로 변경했습니다.
"(?<=----이전-------)((.+\n)+)(?=__________________________________________)"