Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: regular expression: match multiple newlines

by Cristoforo (Deacon)
on Nov 03, 2013 at 19:42 UTC ( #1061065=note: print w/replies, xml ) Need Help??


in reply to regular expression: match multiple newlines

Your code is reading 1 line at a time. You need to 'slurp' the file and apply the regular expression. perl -0 -p -e 's/\n\s*\n/EEEEE/g' textfile

Replies are listed 'Best First'.
Re^2: regular expression: match multiple newlines
by Kenosis (Priest) on Nov 03, 2013 at 19:55 UTC

    Good point! However, \n\s*\n would replace \n\x20\n --a space surrounded by two newlines--which is not two consecutive newlines, thus the prior \n{2,} suggestion.

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

      He stated that there might be spaces between the newlines :-)

        You are indeed correct. My bad. Will strike my postings above.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1061065]
help
Chatterbox?
[Corion]: thezip: Yeah - we have "CAP", but that means "Change Ablauf Plan" (Change Sequence Plan). Likely there is a true ITIL name for this too.
[Corion]: While I'm not really a fan of ITIL, it certainly is better than nothing and it at least provides a common vocabulary, so if you have ITIL somewhere at your disposal, it might be worth a look
[Corion]: Hmm - that should be somewhere in the "Release Deployment Plan", but I don't find a good English link (nor a good German one ;) )
[thezip]: My project manager is asking "Why do we need this?" Ahem...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2017-02-23 17:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (350 votes). Check out past polls.