Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Tricky regex problem (updated)

by AnomalousMonk (Archbishop)
on Jul 22, 2020 at 15:34 UTC ( [id://11119660]=note: print w/replies, xml ) Need Help??


in reply to Tricky regex problem

If that (update: oops... I meant to reply to that node) works for you, try this as a simplification (untested):
$input_text =~ s{ ^ ([#]{2,5}) \s+ [^\n]+ \s+ (?= ^ \1 [^#]) } {}xmsg;
Beyond that, I have to say I don't understand your requirements. Can you express them more clearly?


Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^2: Tricky regex problem (updated)
by nysus (Parson) on Jul 22, 2020 at 15:47 UTC

    All headers that are followed by only whitespace, with the whitespace getting followed by a header with the same or fewer pounds signs as the initial header, should get stripped.

    $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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (None)
    As of 2024-04-25 03:58 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found