Question related to find/replace using propertyregex
In my ant build file, I have a property 'Version' that contains the version. Ex. 2.5.17.230
Now, I am using propertyregex
of ant-contrib to replace all '.' (dot) characters with an underscore. I have written the statement as follows:
<propertyregex property="Version" input="${Version}" regexp="." replace="_" global="true" />
However, it does not work. I have even tried these in vain:
regexp="\."
and regexp开发者_JS百科="[.]"
Can someone please help?
Thanks
The PropertyRegex
documentation states that unless the override
attribute is set to true
, the task will not overwrite the property value if it's already set. And since you're trying to overwrite the Version
property, your example will do nothing.
Got it! I was passing the same variable as input. I used another variable 'Version2' to get the result from propertyregex. Here is what it should have been:
<propertyregex property="Version2" input="${Version}" regexp="\." replace="_" global="true" />
Cheers!
精彩评论