Hi, Matt
thx for your suggestion!
Well, the txtfile i have to alter has actually >40 lines
so with your solution i would have a lot of <echo ...</echo>
And there's also another detail i forgot to mention.
The pattern 'bla' exists 2 times in that txtfile.
the first match is
...
bla
1234
...
and some lines below its :
...
bla
...
So the second match is always followed by a blank line.
That blank line after the second match has to be filled with
a property i get of another script.
The solution must be something like :
<copy file="${mytxtfile}" toFile="newtxtfile">
<filterchain>
<tokenfilter>
<replaceregex pattern="(bla\r\n)(\s\r\n)" replace="helloworld\2"
flags="gm"/>
</tokenfilter>
</filterchain>
</copy>
-> i don't know the exact syntax here ?!,
first group should be the pattern itself, followed by a linebreak,
second group the next (blank) line.
When running, ant shows no syntax error, but the file stays the same.
I've tried with and without flag multiline.
Gilbert
-----Original Message-----
From: Matt Benson [mailto:[EMAIL PROTECTED]
Sent: Wednesday, January 26, 2005 5:02 PM
To: Ant Users List
Subject: Re: putting value in txtfile
--- Erik Hatcher <[EMAIL PROTECTED]> wrote:
> Um.... nevermind..... I missed the part that there is "just a blank
> line". A custom FilterReader would work - have it only affect the 4th
> line.
>
> Erik
All you have to match is the line break count, so assuming you know what
those are (use fixcrlf worst
case) tokenfilter + filetokenizer + replaceregex works. My
self-contained example (with Jakarta ORO as my regexp engine):
<project>
<property name="br" value="${line.separator}" />
<property name="insert" value="hello world" />
<echo file="foo.txt" append="false">01 bla${br}</echo>
<echo file="foo.txt" append="true">02
bla${br}</echo>
<echo file="foo.txt" append="true">03
bla${br}</echo>
<echo file="foo.txt" append="true">04 ${br}</echo>
<echo file="foo.txt" append="true">05 ${br}</echo>
<echo file="foo.txt" append="true">06 ${br}</echo>
<echo file="foo.txt" append="true">07
bla${br}</echo>
<echo file="foo.txt" append="true">08
bla${br}</echo>
<echo file="foo.txt" append="true">09
bla${br}</echo>
<copy file="foo.txt" tofile="bar.txt">
<filterchain>
<tokenfilter>
<filetokenizer />
<replaceregex
pattern="^(.*${br}.*${br}.*${br}.*)(${br}.*)"
replace="\1${insert}\2" />
</tokenfilter>
</filterchain>
</copy>
</project>
-Matt
__________________________________
Do you Yahoo!?
Yahoo! Mail - 250MB free storage. Do more. Manage less.
http://info.mail.yahoo.com/mail_250
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional
commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]