【问题标题】:Using JREPL with Special Characters使用带有特殊字符的 JREPL
【发布时间】:2020-07-18 17:04:14
【问题描述】:

我正在尝试替换以下内容

UninstallPassword="1"

UninstallPassword="0"

我正在使用 JREPL.bat,目前只能替换没有特殊字符的内容。 阅读 /x 下的文档说我必须使用 /q 但我不确定如何格式化它的代码行。我试过了:

jrepl.bat "\qUninstallPassword="1"" "\qUninstallPassword="0"" /f "%userprofile%\pol.txt" /o -

jrepl.bat "UninstallPassword\q=\q"1\q"" "UninstallPassword\q=\q"0\q"" /f "%userprofile%\pol.txt" /o -

但两者都没有更改文本。

感谢任何帮助,或者如果 Windows CMD 有一个内置函数来实现与 JREPL 相同的功能,那么这将是理想的,并将脚本保持为独立的。

【问题讨论】:

  • 如果cmd 中有内置函数,Dave 一开始就不会写jrepl.bat。您可以编写一个脚本(逐行读取和处理文件 - SO上有几个示例),但jrepl 使它更容易、更安全和更快(当您知道如何使用它的众多功能时)。

标签: replace cmd special-characters str-replace jrepl


【解决方案1】:

要使用\q,您必须使用/XSEQ 启用它。然后将\q 用作" 的占位符,因此将模式中的每个" 替换为\q。不要替换围绕模式的外部引号:

jrepl.bat "UninstallPassword=\q1\q" "UninstallPassword=\q0\q" /XSEQ /f "%userprofile%\pol.txt" /o -

【讨论】:

  • 哇,我下午的大部分时间都在努力解决这个问题,让它发挥作用就这么简单。非常感谢斯蒂芬
猜你喜欢
  • 2018-07-02
  • 2014-10-15
  • 1970-01-01
  • 2023-03-14
  • 2012-10-06
  • 2018-11-14
  • 2012-09-15
  • 2017-03-15
  • 1970-01-01
相关资源
最近更新 更多