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 ^^"
In reply to Re: Tricky regex problem
by Eily
in thread Tricky regex problem
by nysus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |