I cannot remove a string containing a backslash with Powershell
(Get-Content $file.fullName).replace('\\mystring', ') | Set-Content $file.fullName
It works if I had to remove 'mystring' only
(Get-Content $file.fullName).replace('mystring', ') | Set-Content $file.fullName
But with a backslash no. What's wrong?
答案 0 :(得分:1)
使用反引号(`)来反转反斜杠。 你的命令看起来像
(Get-Content $file.fullName).replace('`\mystring', '') | Set-Content $file.fullName