开发者

Question related to find/replace using propertyregex

开发者 https://www.devze.com 2023-01-28 05:22 出处:网络
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

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!

0

精彩评论

暂无评论...
验证码 换一张
取 消