ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rebhan, Gilbert" <Gilbert.Reb...@huk-coburg.de>
Subject replaceregex, only the first match
Date Thu, 12 Jan 2006 11:17:43 GMT

Hi,

i have problem with replaceregex.

my script uses a xmlpropertyfile which is generated by
another process.Sometimes there are doubled propertynames
in that file

i have to =
1. load the xmlpropertyfile, check for doubled properties
2. if doubled properties are found, i have to delete the first
   occurence in the propertyfile
3. then unset the loaded properties and load the cleaned
    xmlpropertyfile

so i tried it that way =

1. loading the propertyfile, then using grep task from Antelope
   with a regex to check whether the propertyname in doubt occurs
   two times >>> works fine

2. with if isset property=set via grep task 

then

<copy file="C:/test/props.xml" tofile="C:test/propss.xml">
	<filterchain>
	<tokenfilter>
	<replaceregex byline="false" pattern="&lt;vers.modul\..+"
replace=""/>
	<replaceregex byline="false" pattern="&lt;vers.module.+"
replace=""/>
	<tokenfilter>
	</filterchain>

</copy>

doesn't work as i expected. i thought, when using byline="false" only
the
first match of my regex is replaced, but all occurences are replaced.
i tried also several flags with the same result.

3. then unset all properties of the original xmlproperty via unset task
    from Antelope, move the cleaned up xmlproperty to the original
    file name, as this name is referenced in several other following
scripts
    and load it again

Questions =

- how to replace only the first match via replaceregex ?
- are there any other ways with ant ?

Any hints ?

Regards, Gilbert

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message