in reply to remove single blank lines?
I bid you welcome to the wonderful world of regular expressions (aka regexes). More information can be learned about these from perlre. Here's my version:
my $string = q{ this is a sample text. all single blank lines will be removed. all double, triple, or more blank lines will not be touched. }; $string =~ s#\n(\n+)#"\n" x (length($1)>1 ? length($1)+1 : length($1))#eg; print $string; __END__ this is a sample text. all single blank lines will be removed. all double, triple, or more blank lines will not be touched.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: remove single blank lines?
by hmerrill (Friar) on Dec 08, 2003 at 22:23 UTC |