http://qs321.pair.com?node_id=11119658

nysus has asked for the wisdom of the Perl Monks concerning the following question:

Got a regex:

$input_text =~ s/^###*\s+[^\n]+\s+(?=^##)//gsm;

I want it to strip out markdown headers from a file that don't contain anything:

## This gets stripped ## This doesn't Because it contains this line ## More headers blah blah

But I also don't want it to strip this:

## 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

Is there any way at all to pull this off with a regex?

$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest Vicar";
$nysus = $PM . ' ' . $MCF;
Click here if you love Perl Monks