Keep the backslashs in propertyregex

Wednesday, November 4, 2015

I'm trying to replace a directory path string in a XML file using ANT with the value stored in variable ${param_value}.



In my example ${param_value} contains c:\mypath\mydir



In order to replace as wished, I use propertyregex.



The issue is that the regex replace value is c:mypathmydir
I don't understand why "replace" removes all backslashes.



When I echo to check the value of my variable before regex, it looks like:



<echo message="param_value out=${param_value}"/>


This echo returns c:\mypath\mydir



${param_token} is xml token (output)



<propertyregex      property="param_temp"
input="${result}"
regexp="(&lt;${param_token})&gt;(.*|\\)*&lt;(/${param_token}&gt;)"
replace="\1&gt;${param_value}&lt;\3"
casesensitive="false"
defaultvalue="NotFound"/>


Thank you for your help.

0 comments:

Post a Comment