Re: Remove blank lines from a file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

best,

nathan

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux