Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
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 pondering the Monastery: (4)
As of 2023-04-01 18:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?