Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Tricky regex problem

by tybalt89 (Monsignor)
on Jul 22, 2020 at 16:00 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11119663]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (8)
As of 2024-03-28 12:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found