Raghu M
Raghu M

Reputation: 9

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="[.]"

Can someone please help?

Thanks

Upvotes: 0

Views: 5426

Answers (2)

Raghu M
Raghu M

Reputation: 9

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!

Upvotes: 0

skaffman
skaffman

Reputation: 403461

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.

Upvotes: 6

Related Questions