How do I replace multiple newlines with a single one with Perl's Regular Expressions?
Posted
by Simon A. Eugster
on Stack Overflow
See other posts from Stack Overflow
or by Simon A. Eugster
Published on 2010-05-27T19:04:53Z
Indexed on
2010/05/27
19:11 UTC
Read the original article
Hit count: 151
I've got a document containing empty lines (\n\n). They can be removed with sed:
echo $'a\n\nb'|sed -e '/^$/d'
But how do I do that with an ordinary regular expression in perl? Anything like the following just shows no result at all.
echo $'a\n\nb'|perl -p -e 's/\n\n/\n/s'
© Stack Overflow or respective owner