我有一個.tex
文件,我想將其中的字串替換a\a{nn}o
為a(nn)o
我嘗試過以下 PowerShell (v5) 程式碼:
(Get-Content h:\combined.tex) | ForEach-Object { $_ -replace "a\a{nn}o", "a(nn)o" } `
| Set-Content h:\combined2.tex
它運行了,但文字沒有任何變化。我究竟做錯了什麼?
答案1
我讓它與以下內容一起工作:
$(Get-Content .\temp) -replace "123","ABC" | Set-Content temp2
這為了循環是不必要的,我相信它(或管道)可能會導致問題