Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Tricky regex problem

by tybalt89 (Prior)
on Jul 22, 2020 at 16:00 UTC ( #11119663=note: print w/replies, xml ) Need Help??


in reply to Tricky regex problem

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11119658 use warnings; $_ = <<END; ## This gets stripped ## This doesn't Because it contains this line ## More headers blah blah ## this also should be stripped ? ## This should not get stripped, but it does ### This should prevent it from getting stripped, but it doesn't stuff #### This should also not get stripped ##### But it does isn't some text needed here? END s/^(#+).*\n\n(?!^\1#)//gm; print;

Outputs:

## This doesn't Because it contains this line ## More headers blah blah ## This should not get stripped, but it does ### This should prevent it from getting stripped, but it doesn't stuff #### This should also not get stripped ##### But it does isn't some text needed here?

I think a larger test case may be needed...

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2021-04-18 14:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?