我想替换 ?
在
"EquipmentInfo["?"] = "<iframe src='http://bing.fr'></iframe>";"
通过变量。
我尝试过这个:
(get-content C:\word.txt) -replace '?', '$obj' | Set-Content C:\word.txt
最佳答案
我会使用积极的回顾来确保您找到正确的问号。此外,您还必须在替换项上使用双引号,因为您想替换变量:
(get-content C:\word.txt -raw) -replace '(?<=EquipmentInfo\[")\?', "$obj" | Set-Content C:\word.txt
使用的正则表达式:
(?<=EquipmentInfo\[")\?
关于powershell - 使用 powershell 替换链接中的字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37679977/