In Ant, I have a property named ‘some_property‘, and let’s say its value is “hello“.
I’m trying to replace a place-holder inside a text file with this property’s value (“hello“) as an upper-case.
So, I have this task:
<replaceregexp match="SOME_PLACE_HOLDER" replace="${some_property}" byline="true">
And I want it to work as if I would have this task:
<replaceregexp match="SOME_PLACE_HOLDER" replace="HELLO" byline="true">
I wish to avoid external Ant tasks (such as Ant-Contrib), therefore the solution needs to be a pure regex – it must be possible!
UPPERCASE, lowercase, and Capitalized.
Anyone knows the correct regexes?
I understand that you want to avoid Ant extensions, but the constraint that the solution be implemented using regex is a little tight – apologies if the following bends (breaks?) that rule too much.
Ant ships with a javascript engine these days, so anything that seems problematic to implement in Ant xml can usually be hidden away in a
scriptdef. Below are four that do case changing.In your case, you would take your
some_propertyproperty and process it through theupperscript to get an uppercased version of the string to use in thereplaceregexptask.Example use:
And output:
Thanks to Poni and Marco Demaio for the implementation of the Capitalization.