I am writing an Ant script that removes content from a properties file.
Say the properties file is called abc.properties and one of the properties is as such:
this.property=monkey,banana,peanuts,ate,tiger,what,the,heck
My script has to be able to remove one of the items without disturbing the order. Right now, I have this:
<replaceregexp file="@{targetDir}/setup/properties/abc.properties"
match="this.property(.*),tiger(.*)"
replace="this.property\1\2"/>
Currently, the regular expression works for anything except monkey. I could replace tiger with what, peanuts, or anything except monkey because all of them have a comma in front of them. If I removed the comma from my match expression, there would be an extra comma. The question is, how would I go about writing the regular expression that would replace any item, including monkey?
Thanks
Edited 10-July-2011 to incorporate excellent suggestions of inTide:
How about
This will leave a bogus terminating comma for “heck” – the last choice. Remove this is a second pass: