One of the neat things about regular expressions is the use of [^x]
which means any character besides x
. This is a great thing when you have to thwart the greediness of regular expressions. For example, [^:]*
means select all characters up to the next colon:
<propertyregex property="builderName"
input="${componentLine}"
regexp="[^:]*:([^:]*)"
select="\1"
override="true"/>
The first [^:]*:
matches COMPONENT:
. This says match the entire string that doesn't contain a colon, and the colon that follows it. (You see how this works?)
The next ([^:]*)
matches MyBuild
. It's similar to the first, except it doesn't have a colon, so the colon following MyBuild
won't be included. It's surrounded by parentheses because I want to capture it.
Instead of the replace
parameter, I use the select
parameter which allows me to say that I want to replace the whole string with just the first capture group (what's in parentheses).
I haven't tested this, but it should work, or at least point you in the right direction.