in reply to Text::Balanced with nested / custom brackets
my $extractor; # Must be a seperate statement. $extractor = qr/ \[\[ (?: (?: (?! \[\[ | \]\] ) . )+ | (??{ $extractor }) )+ \]\] /x; my @links = $text =~ /$extractor/g;
Optimized (I think):
my $extractor; # Must be a seperate statement. $extractor = qr/ \[\[ (?> (?: (?: (?> [^\[\]]+ ) | \[ (?! \[ ) | \] (?! \] ) ) | (??{ $extractor }) )+ ) \]\] /x; my @links = $text =~ /$extractor/g;
Tested.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Text::Balanced with nested / custom brackets
by Anonymous Monk on Sep 07, 2006 at 22:18 UTC | |
by ikegami (Patriarch) on Sep 07, 2006 at 22:36 UTC | |
|
Re^2: Text::Balanced with nested / custom brackets
by wojtyk (Friar) on Sep 08, 2006 at 15:56 UTC |