【问题标题】:Using REPL.bat to find and replace when bracket '(' is present in phrase being replaced当括号“(”出现在被替换的短语中时,使用 REPL.bat 查找和替换
【发布时间】:2014-03-20 20:11:20
【问题描述】:

尝试使用 dbenham 的 REPL.bat 来查找和替换包含括号 '(' 的短语

需要将 XML 中以下字符串中的 (local) 替换为 192.168.1.1

  <add name="JobRepository" connectionString="Data Source=(local);Connection Timeout=180;Integrated Security=SSPI;Initial Catalog=JobRepositorydb"

使用type input.file |repl "(local)" "192.168.1.1" &gt;output.file

生产:

  <add name="JobRepository" connectionString="Data Source=(192.168.1.1);Connection Timeout=180;Integrated Security=SSPI;Initial Catalog=JobRepositorydb"

但我需要:

  <add name="JobRepository" connectionString="Data Source=192.168.1.1;Connection Timeout=180;Integrated Security=SSPI;Initial Catalog=JobRepositorydb"

【问题讨论】:

    标签: batch-file replace find read-eval-print-loop


    【解决方案1】:
    type input.file |repl "(local)" "192.168.1.1" L >output.file
    

    您需要指出搜索字符串是文字而不是正则表达式。

    【讨论】:

    • 简单地修改文件而不是管道到新文件(然后覆盖)的正确语法是什么?
    • 在 Windows NT 及更高版本中,您无法在批处理脚本中修改或重用相同的文件名。您必须使用新文件名,然后将 move 改成旧文件名,或者将 del 旧文件和 ren 新文件名改成旧文件名。
    猜你喜欢
    • 2014-09-01
    • 1970-01-01
    • 2014-03-09
    • 2015-08-06
    • 1970-01-01
    • 2016-08-22
    • 2011-02-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多