ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject RE: Using ReplaceRegExp
Date Thu, 26 Sep 2002 14:04:38 GMT
okay that was actually the first thing I'd tried. later I used this:

<replaceregexp file="temptest.csv" match="^(([^;]*;){30})([^;]*)(;)$"
replace="\1\3" byline="true" />

This worked fine (it removed the 31rst semi-colon from each line). Then I
wanted to add 00 if the 31rst column of my CSV file was missing, so I think
I tried (sorry I deleted it) :

<replaceregexp file="temptest.csv" match="^(([^;]*;){30})$" replace="\100"
byline="true" />

now if I put replace="\1'00'", it added '00' to the end of each line where
the 32rst column was missing, but I didn't want the single quotes, but with
just \100 (as in \1 and 00), it didn't work. I supposed it interpreted it as
"give me the 100th result".

Now I read somewhere that you could match a caracter by using it's octal
value as \nnn, or its hexadecimal value with \x, but this is supposedly for
matching, and not for the replacement.

As i don't know much about regular expressions, it's got me beat. Any ideas?


-----Message d'origine-----
De : Stefan Bodewig []
Envoye : jeudi 26 septembre 2002 15:42
A :
Objet : Re: Using ReplaceRegExp

On Tue, 24 Sep 2002, <> wrote:

> Thanks for that. now I wanted to add a value at the end
> <replaceregexp file="temptest.csv" match="(.);$" 
>                replace="\1<a value>" byline="true" />
> now if i put replace="\100" to add a '00' (reusing the result '\1'),
> it doesn't work.

What is the result?

\1 will only match the very last character of the line (in front of
the ";"), you probably want to use (.*) instead.


To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message