"What can a one liner do for you?" - Frankly Speaking
function removeEmptyLines($string){ return preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $string);}
Nice. I staved off learning regexes yet another day.
You are a wizard indeed! I'm going to try it right now.
Awesome. Thanks!
Thanks.. this tips is great!
Hello, \t ∈ \s — it can be simplified further.
Thanks Very Much....Its Very Userfull...Thankssulistianto.adi@gmail.comAdi SulistiantoIndonesia
Thank you very much, i was been trying of hours to get this rid of , your work is really great By chavansoft
Yes - this is exactly what I was searcing. Many thanks!!Br, Kari..
This is excellent, it has saved me loads of time, thank you so much!
This is my solution.$s = preg_replace('/^\n+|^[\t\s]*\n+/m','',$s);
Bythos your code worked. the code from the "topic starter" did not in my case. Thx. very useful.
plug and play perfect, worked like a charm.
@Bythos thanks! Your solution works for me, topic-starter - not.
Very usefulBut if you want to remove all duplicated blank lines but want to preserve legibility, just replace, in the RegExp, the first '+' with {2,} and add one more \n in replacement.
my code is hereit can take care of a folder including sub folders.http://blog.slesolutions.com/2010/12/blank-line-remover-in-folder-and-subfolders/
I like to use an online tool for that: https://www.funender.com/free_online_tools/index.php
Oops here is active link: Multiple whitespace remover
Amazing ....
A thing of beauty that has made me very happy after a frustrating 48 hours coding :) Many thanks.
Thanks........
The purpose of education is to replace an empty mind with an open one. See the link below for more info. #emptywww.mocsbar.com
Interesting details you have remarked, thank you for putting this article together. www.triciajoy.com
I must appreciate your post which is helping us in such a great manner. Brywww.gofastek.com
If you want each line in an array, with no empty lines, try:$lines = explode("\n",$multi_line_string);$lines = array_filter($lines);Good luck y'all!
good job. It make me resolve many problems. So thank you, guys.
Post a Comment
25 comments:
Nice. I staved off learning regexes yet another day.
You are a wizard indeed! I'm going to try it right now.
Awesome. Thanks!
Thanks.. this tips is great!
Hello, \t ∈ \s — it can be simplified further.
Thanks Very Much....
Its Very Userfull...
Thanks
sulistianto.adi@gmail.com
Adi Sulistianto
Indonesia
Thank you very much, i was been trying of hours to get this rid of , your work is really great By chavansoft
Yes - this is exactly what I was searcing. Many thanks!!
Br, Kari..
This is excellent, it has saved me loads of time, thank you so much!
This is my solution.
$s = preg_replace('/^\n+|^[\t\s]*\n+/m','',$s);
Bythos your code worked. the code from the "topic starter" did not in my case.
Thx. very useful.
plug and play perfect, worked like a charm.
@Bythos thanks! Your solution works for me, topic-starter - not.
Very useful
But if you want to remove all duplicated blank lines but want to preserve legibility, just replace, in the RegExp, the first '+' with {2,} and add one more \n in replacement.
my code is here
it can take care of a folder including sub folders.
http://blog.slesolutions.com/2010/12/blank-line-remover-in-folder-and-subfolders/
I like to use an online tool for that: https://www.funender.com/free_online_tools/index.php
Oops here is active link: Multiple whitespace remover
Amazing ....
A thing of beauty that has made me very happy after a frustrating 48 hours coding :) Many thanks.
Thanks........
The purpose of education is to replace an empty mind with an open one. See the link below for more info.
#empty
www.mocsbar.com
Interesting details you have remarked, thank you for putting this article together.
www.triciajoy.com
I must appreciate your post which is helping us in such a great manner.
Bry
www.gofastek.com
If you want each line in an array, with no empty lines, try:
$lines = explode("\n",$multi_line_string);
$lines = array_filter($lines);
Good luck y'all!
good job.
It make me resolve many problems.
So thank you, guys.
Post a Comment