Чтобы RegEx рассматривал ваш ввод из файла как одну строку, вам нужно либо использовать Get-Content
с параметром -raw (PSv3 +)
-или-
используйте -join для объединения массива строк в одну строку.
Использование всего текста вопроса, хранящегося в файле sample.txt:
> (Get-Content .\sample.txt -raw) -replace '\][\r\n]+\[',','
Having troubles in PowerShell writing the regex to replace the following multiple occurrences of the below inside a file. They are the only characters on those lines
,
I want to replace both brackets with a comma
before:
,
after:
,
Any suggestions?