ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Raymond Berg (ALLETE)" <>
Subject RE: Multiple
Date Thu, 03 Jul 2008 13:44:10 GMT
Sorry for the delayed response! Thanks for the suggestion, but I'm not
totally comfortable creating another language dependency for the task.
That's not to say that this isn't the faster, if not altogether better,
solution for this issue. 

You are right, though, the solution is to evaluate files and perform
multiple replacements on each provided string. My apologies for the


-----Original Message-----
From: Jim Cant [] 
Sent: Wednesday, July 02, 2008 8:40 PM
Subject: Re: Multiple

If I understand your problem correctly, what you are trying to do is do
global search and replace in a file.  I don't think ant is the
tool for this; I'd suggest Perl.  Here's a command that replaces every
occurence of each pattern in a line for all lines in a file and saves
original file 'fileIn.txt' to 'fileIn.txt.bak

perl -i.bak -ape "s/pat1/repl1/g;s/pat2/repl2/g;...;s/patN/replN/g"

You should be able to run this with the <exec> task.

Note that if a replacement results in a line that matches a pattern that
match later, that replacement will be made which may not be what you

Raymond Berg (ALLETE) wrote:
> I've got a situation where I need to search deployment files for
> server names of a variable count when moving from staging to
> automatically. However, I can't seem to figure out how to handle a
> dynamic replace count. I was looking at the script task but found no
> syntax that seemed to help. (Also investigated path tools and the few
> string operations available)
> I'm debating whether to create a new Ant task, but I'm not comfortable
> enough with my skills yet to attempt this.
> If it helps, my script is currently passing in a single delimited
> as follows: find1~replace#find2~replace2#...#findn~replacen
> Any ideas?
> Raymond
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

View this message in context:
Sent from the Ant - Users mailing list archive at

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

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

View raw message