Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Re: Maximal match in a recursive regex

by Mr. Muskrat (Canon)
on Jun 26, 2003 at 17:35 UTC ( #269327=note: print w/replies, xml ) Need Help??

in reply to Re: Maximal match in a recursive regex
in thread Maximal match in a recursive regex

This is how I fixed it.

my $re; $re = qr/ \[ # Opening bracket ( # Capture the contents [^][]+ # Body of a link | (??{$re}) # Or recurse )+ # added per diotalevi's instructions \] # Closing bracket /x; $k = "a[b[c[d]]"; $k =~ s/($re)/<$1>/g; # I added the ()'s :) print $k;

Bah! It captures the outer square brackets too :(

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2016-10-01 04:19 GMT
Find Nodes?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:

    Results (574 votes). Check out past polls.