首页 > 解决方案 > 用引号和斜杠替换字符串

问题描述

我在文件中有以下字符串:

应用程序=\“我的应用程序\”

我想用 PowerShell 命令删除它(或用''替换)。

我试过这个,但没有奏效:

powershell -Command "Get-ChildItem -Path ./Transform\*.json -recurse | ForEach {If (Get-Content $_.FullName | Select-String -Pattern ' where useraction.application=\\\"MyApp\\\"') {(Get-Content $_ | ForEach {$_ -replace ' where useraction.application=\\\"MyApp\\\"', ' '}) | Set-Content $_ -encoding UTF8}}"

我认为在每个特殊字符前面加上反斜杠会起作用,但到目前为止还没有运气。

标签: powershell-3.0

解决方案


推荐阅读