【发布时间】:2015-12-02 14:56:40
【问题描述】:
使用 ANT 我正在尝试使用 ANT replaceregexp 任务查找/替换带有空格和双引号的字符串。
xml中的实际标签
<ser:debug enabled="false">
以下都失败了。
"<replaceregexp file="filepath" match="debug enabled="false"" replace="debug enabled="true"" byline="true" />"
和
"<replaceregexp file="filepath" match="debug\ enabled\=\"false\"" replace="debug\ enabled\=\"true\"" byline="true" />"
我收到此错误:
元素类型“replaceregexp”必须后跟属性规范,“>”或“/>”
但是,对于不同的标签,这个工作正常,没有任何问题......因为没有这样的特殊字符。
<replaceregexp file="filepath" match="sql-debug-mode>true" replace="sql-debug-mode>false" byline="true" />
【问题讨论】:
-
用 xml char 实体尝试过这种方式(不确定我做的是否正确)
<replaceregexp file="filepath" match="debug enabled=&quotfalse&quot" replace="debug enabled=&quottrue&quot" byline="true" />但出现此错误 对实体“quotfalse”的引用必须以 ';' 结尾分隔符。 -
您错过了实体上的分号:
&quot; -
非常感谢,也试过用 ' 单引号括起来……这行得通
标签: java .net regex ant build-automation