4

I'm trying to use Ant for replacing value in xml.

My xml file:

<session-config>
    <session-timeout>60</session-timeout>
</session-config>

I want to replace 60 to 20

And use for this following regexp in ant task 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>

But got fatal error from ant after execution:

[Fatal Error] The value of attribute "match" associated with an element type "replaceregexp"
 must not contain the '<' character.

Please advise, how to change my regexp, or maybe there is an another solution of this problem? Thanks.

1 Answer 1

5

< and > characters must be "escaped" by using &lt; and &gt; respectively:

<replaceregexp file="WEB-INF/web.xml"
              byline="true"
              match="((?&lt;=session-timeout\&gt;)[\S\s]*?(?=\&lt;\/session-timeout))"
              replace='20'/>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.