Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: regular expression: match multiple newlines

by Kenosis (Priest)
on Nov 03, 2013 at 19:38 UTC ( #1061064=note: print w/replies, xml ) Need Help??


in reply to regular expression: match multiple newlines

Try:

s/\n{2,}/EEEEE/g

Output on your dataset:

dogs rats catsEEEEEfish

The \n{2,} notation matches 2+ newlines.

Edit: My apologies. Didn't notice the the OP's mentioning the possibility of other whitespace between the newlines.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1061064]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (10)
As of 2017-06-26 13:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (580 votes). Check out past polls.