ant replaceregexp xml 换行符

ant replaceregexp xml newline

我正在尝试使用 ANT replaceregexp 任务将 xml 元素值从 "true" 更改为 "false",但在匹配新行时遇到困难。有问题的XML节点的相关部分:

<validationRules>
    <fullName>CAReversaApprovallLockdown</fullName>
    <active>true</active>

在我的文本编辑器 (sublime) 中,我可以使用以下正则表达式 find/replace 但我不知道如何在 ANT replaceregexp 中复制它:

/fullname>\n        <active>true

我想不出正确的语法来匹配换行符和后面的空格的组合。换行符后的间距总是相同的,如果这样更容易的话。

查看 https://ant.apache.org/manual/Tasks/replaceregexp.html 我尝试了 ^ 和 $ 与 m 标志的各种组合,\s+ 用于空格等,但就是无法找到正确的组合....有什么想法吗?

我目前的进度低于但很不幸......

<target name="deactivate_val_rules">
    <echo message="deactivating validation rules..." />
    <replaceregexp match="/fullname&gt;\r\n\s+&lt;active&gt;true" flags="gim" byline="false">
        <substitution expression="/fullname&gt;\r\n        &lt;active&gt;false"/>
        <fileset dir="src\objects" includes="Claim_Approvals__c.object"/>
    </replaceregexp>
</target>

要使用 replaceregexp 您需要定义要更改的值作为参考。

例如:

<validationRules>
    <fullName>CAReversaApprovallLockdown</fullName>
    <active>true</active>

蚂蚁:

<target name = "deactivate_val_rules">
    <echo message="deactivating validation rules..." />
    <replaceregexp file="${FILE_LOACTION}/FILE_NAME.FILE_EXT" match="true" replace="false" />   
</target>

知道了 - 以下给出了正确的结果:

<target name="deactivate_val_rules">
    <echo message="deactivating workflows..." />
    <replaceregexp match="/fullname&gt;\r\n\s+&lt;active&gt;true" flags="gis" byline="false">
        <substitution expression="/fullname&gt;${line.separator}        &lt;active&gt;false"/>
        <fileset dir="src\objects" includes="Claim_Approvals__c.object"/>
    </replaceregexp>
</target>

通过 diff 查看的输出是:

  -  <fullName>the_name</fullName>
  -  <active>true</active>
  +  <fullName>the_name</fullname>
  +  <active>false</active>