windows - 从批处理文件执行powershell命令时转义双引号
问题描述
我必须在 PowerShell 命令中使用正则表达式替换命令。替换为 RegEx 仅适用于双引号 (")。此外,要在批处理文件中执行 PowerShell 命令,该命令必须在双引号 (") 内,如下所示:
powershell -command ""
那么,有没有办法逃避与替换命令一起使用的双引号,因为以下由于双引号冲突而引发错误:
powershell -command "$content -replace ",$", ",NULL""
我试过使用 (`) 像:
powershell -command "$content -replace `",$`", `",NULL`""
有人可以提出一些解决方案吗?
解决方案
这是一个迟到的回应,但你可以'
在双引号之间使用引号,然后你可以这样写:
powershell -command "$content -replace ',$', ',NULL'"
推荐阅读
- migration - 将消费逻辑应用迁移到标准
- javascript - 使用“文本框”创建问卷 Javascript
- python - 通过 lambda 测试测试 Rotating Secret
- python-3.x - 您如何将 1 周的 yfinance 间隔设置为默认为星期五而不是星期一?
- swift - Firebase 登录后不显示用户
- python - IDA Pro:如何获取导入函数?(或获取导入表列表的 API)
- javascript - 如何使用 VUE 为课程添加条件
- xcode - Can you change info.plist inside a Run Script in Xcode's Build Phase?
- c - 分配基地址的指针数组给出错误
- python - 如何使用 API 从 Google 电子表格导出二进制图像?