in reply to How to find the outermost pair of square brackets with a regex?
With difficulty.
our $re; local $re = qr{ \[ (?: (?> [^\[\]]+ ) | (??{ $re }) )* \] }x; my $s = <<'__EOI__'; blah blah blah blah blah blah blah blah [blah [blah blah] [blah blah blah blah] blah] blah blah __EOI__ $s =~ s/$re/moo/g; print($s);
Partial credits to perlre.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to find the outermost pair of square brackets with a regex?
by lokiloki (Beadle) on Jan 17, 2007 at 01:18 UTC | |
by lokiloki (Beadle) on Jan 17, 2007 at 01:20 UTC | |
by lokiloki (Beadle) on Jan 17, 2007 at 02:26 UTC | |
|