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.
In reply to Re: How to find the outermost pair of square brackets with a regex?
by ikegami
in thread How to find the outermost pair of square brackets with a regex?
by lokiloki
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |