ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Davor Cengija <davor.ceng...@mail.inet.hr>
Subject [Fwd: Remove empty lines from a file?]
Date Mon, 16 Sep 2002 16:15:23 GMT
Hehe, mail manager works just fine. Sorry if this message appears twice.

-----Forwarded Message-----

From: Davor Cengija <davor.cengija@mail.inet.hr>
To: Ant Users List <ant-user@jakarta.apache.org>
Subject: Remove empty lines from a file?
Date: 16 Sep 2002 17:35:57 +0200

I'm looking for a task which will remove all empty lines from a file.
Searching the mail archives I found some mentionings of replaceregexp
task, but I cannot force it to work as I wish.

I wrote my own custom task (first ever, I stared using Ant yesterday :-)
but it is rather cumbersome: it creates a temporary file, copies the
non-empty lines to it and then calls java.io.File#rename().

I'd be much more happier with 'native' ant task, probably without temp
files.

I'm using Ant 1.5.0 stable (+jakarta-oro-2.0.6 I think)

Any help is greatly appreciated.

Thanks!


P.S. Maybe I don't need removeemptylines task at all if I knew how to
use replaceregexp properly. I need to prepare some database dumps for
the distribution. Those dumps contains table definitions, as well as the
INSERT INTO lines. When I strip down those INSERT INTO lines, I have a
file with a few thousands of empty lines which I just don't want to be
there.

This is how I use replaceregexp:

<replaceregexp 
	file="${file}"
	match="^INSERT.INTO.*$$"
	replace=""
	byline="true"
	flags="s"/>


Regexp is matched but CR/LF remains regardes of the flag I use. 

One important issue: when the first INSERT INTO is encountered,
everything after that until the end of file can be stripped.

Is the replaceregexp the solution for my problem?

Thanks again :-)




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


Mime
View raw message