Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2016-12-09 23:42 GMT
Find Nodes?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:

    Results (158 votes). Check out past polls.