如何在 Ant 中使用正则表达式替换 xml 标签之间的值?

Bor*_*lov 4 regex xml ant

我正在尝试使用 Ant 替换 xml 中的值。

我的 xml 文件:

<session-config>
    <session-timeout>60</session-timeout>
</session-config>
Run Code Online (Sandbox Code Playgroud)

我想更换6020

并在 ant 任务中用于以下正则表达式replaceregexp

(?<=session-timeout>)[\S\s]*?(?=</session-timeout)


<target name="step1">
        <replaceregexp file="WEB-INF/web.xml"
                       byline="true"
                       match="((?<=session-timeout\>)[\S\s]*?(?=\<\/session-timeout))"
                       replace='20'/>
</target>
Run Code Online (Sandbox Code Playgroud)

但是在执行后得到了来自ant的致命错误:

[Fatal Error] The value of attribute "match" associated with an element type "replaceregexp"
 must not contain the '<' character.
Run Code Online (Sandbox Code Playgroud)

请指教,如何更改我的正则表达式,或者这个问题有另一种解决方案吗?谢谢。

man*_*uti 5

<>字符必须分别使用&lt;和进行“转义” &gt;

<replaceregexp file="WEB-INF/web.xml"
              byline="true"
              match="((?&lt;=session-timeout\&gt;)[\S\s]*?(?=\&lt;\/session-timeout))"
              replace='20'/>
Run Code Online (Sandbox Code Playgroud)