You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by shindito <at...@gmail.com> on 2010/06/30 09:25:56 UTC
replaceregexp task
Hello, everyone,
I want to replace a given pattern in a html file with some expression, I'm
using regexp. The problem is, that my script replaces only one expression
per line, in case of 2 expressions to be replaced on one line, it doesn't
work.
Here is the target:
<target name="Regular expr example">
<replaceregexp flags="g" byline="true">
<fileset dir="${some folder}">
<include name="**/*.html"/>
</fileset>
<regexp pattern="<a href="./(\w+)/(.*).html">" />
<substitution expression="<a href="./ \2.html">" />
</replaceregexp>
</target>
And here is a line from html, containing two matchs:
<td class="chart"> ./junit-count-chart.html Count /
./generated_reports/junit-rate-chart.html Rate </td>
I've set flags to g=global, but still not working. I've tryed all flags...
It only replaces the first regexp on the line.
Thanks for your help.
--
View this message in context: http://old.nabble.com/replaceregexp-task-tp29031606p29031606.html
Sent from the Ant - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: replaceregexp task
Posted by Mark Salter <ma...@talktalk.net>.
On 30/06/2010 08:25, shindito wrote:
> I've set flags to g=global, but still not working. I've tryed all flags...
> It only replaces the first regexp on the line.
Please try changing byline="true" to byline=false (or just let it default)?
From:-
http://www.jajakarta.org/ant/ant-1.6.1/docs/en/manual/OptionalTasks/replaceregexp.html
( http://tinyurl.com/replaceregexp )
"
byline
Process the file(s) one line at a time, executing the
replacement on one line at a time (true/false).
This is useful if you want to only replace the first
occurence of a regular expression on each line, which
is not easy to do when processing the file as a whole.
Defaults to false.
"
--
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org