
次の正規表現を使用しようとしています:
(?<=----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/そして出典:http://www.regexpal.com正規表現は期待どおりに動作しています。
助けてください。
$ModifyOldRegex = "(?<=----Old-------\n)(((.+\n)+)\n*?)(?=__________________________________________)"
$Description | Select-String -Pattern $ModifyOldRegex.matches.Value
答え1
ついに問題が見つかりました:
1- get-Content -Raw を使用すると \n が機能する // 理由は不明
2-正規表現を次のように変更しました
「(?<=----古い-------)((.+\n)+)(?=__________________________________________)」