ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Josep del Río <josep....@uworks.net>
Subject RE: Remove blank lines
Date Wed, 18 Feb 2004 23:28:48 GMT
I think that the following should do the trick:

  	    <replaceregexp flags="g" byline="false">
  	        <regexp pattern="\r\n[\s]*\r\n[\s]*\r\n"/>
  	          <substitution expression="&#13;&#10;&#13;&#10;"/>
  	          <fileset dir="${dist}">
  		        <filename name="**/*.php"/>
  	          </fileset>
  	    </replaceregexp>

Where "\r\n[\s]*\r\n[\s]*\r\n" means 2 blank lines and
"&#13;&#10;&#13;&#10;" means 1 blank line, so the maximum of blank lines
will be 1.



-----Original Message-----
From: Jürgen Hauser [mailto:hauser@pandora.be] 
Sent: miércoles, 18 de febrero de 2004 20:35
To: user@ant.apache.org
Subject: Remove blank lines

Hi,

I'm having troubles finding out how to actually remove blank lines.

I have a regular expression which will match all blank lines, but since
it 
needs to be replaced with something, you get the problem ;)

  	    <replaceregexp flags="g" byline="true">
  	        <regexp pattern="^[\s]*$"/>
  	          <substitution expression=""/>
  	          <fileset dir="${dist}">
  		        <filename name="**/*.php"/>
  	          </fileset>
  	    </replaceregexp>	

To be honest, what i would really like to achieve is to have it remove 
blank lines only if there are two or more blanklines in a row, so it
still 
leaves one blank line.

ie.

1. $foo = 'bar';
2. blank line
3. blank line
4. $user =& new User();
5. blank line
6. $user->doSomething();

would result in

1. $foo = 'bar';
2. blank line
3. $user =& new User();
4. blank line
5. $user->doSomething();

Thanks a lot in advance!

Regards,
Jürgen



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



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


Mime
View raw message