Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Tricky regex problem

by Eily (Monsignor)
on Jul 22, 2020 at 15:55 UTC ( #11119662=note: print w/replies, xml ) Need Help??


in reply to Tricky regex problem

Not a single regex but one way to do what you want is to read your file in paragraph mode, with $/ and split the logic:

{ local $/ = ""; # Edit: added use of local for good practice while (<DATA>) { s/^##.*//s unless /^\w/m; print; } } __DATA__ ## Remove ## Keep this ## Remove ## Also keep that

Otherwise you could use a negative look ahead assertion (?!^\w)

Edit: seems like I really didn't read the requirement well enough ^^"

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11119662]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (None)
    As of 2021-10-21 06:13 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      My first memorable Perl project was:







      Results (82 votes). Check out past polls.

      Notices?