Re: Remove blank lines from a file

From: Date: Mon, 24 May 2010 03:05:08 +0000
Subject: Re: Remove blank lines from a file
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17  Groups: php.general 
Request: Send a blank email to php-general+get-305476@lists.php.net to get a copy of this message
Nathan Rixham wrote:
Robert Cummings wrote:
Nathan Rixham wrote:
Yes it was client stripping out extra whitespace! thanks Rob, replicated your results: 1 2 3 4 5 6 and then 'fixed' to give what's needed: preg_replace( "/(((\r|)\n)(\h*|))+/im", '\\1' , $input ); the above keeps line termination the same as in the source file; can you give it a quick check your side to ensure it works (if you don't mind)?
No, no, you missed my meaning... I don't care about line ending... I care about trailing whitespace on non-empty lines.
modified one that 'cleans' the new lines: preg_replace( "/((\r|)\n(\h*|))+/im", PHP_EOL , $input );
Yes, this is preferred with respect to line ending IMHO. But it still strips trailing whitesapce. Almost there... but you've also got that first blank line still hanging around which is supposed to be removed :D
lol ahh hell yeah; trim() it ;) I'm done for the night
*rofl* Have a good night :D Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized.

« previous php.general (#305476) next »