Update: Per haukex's query, the version of Regexp::Common::balanced I'm using is 2010010201, so yes, I'm a bit behind the times and the behavior of 1nickt's code is not unexpected.
c:\@Work\Perl\monks>perl -wMstrict -le "use Regexp::Common qw(balanced); print $Regexp::Common::balanced::VERSION; " 2010010201
Are you sure about that code? I can only generate the given output when I add the -keep switch to the RE_balanced() call.
Without -keep:
With -keep:c:\@Work\Perl\monks>perl -wMstrict -le "use strict; use warnings; use 5.010; use Regexp::Common 'RE_balanced'; my $string = 'The use of parentheses (indicates that the ' . '(writer [considered] the {information}) less ' . '<importantalmost> an afterthought).'; my $match = RE_balanced( -parens => '(){}[]<>' ); $string =~ s/${match}.*//; $1 and say \"^>$_^<\" for $string, $1; "
c:\@Work\Perl\monks>perl -wMstrict -le "use strict; use warnings; use 5.010; use Regexp::Common 'RE_balanced'; my $string = 'The use of parentheses (indicates that the ' . '(writer [considered] the {information}) less ' . '<importantalmost> an afterthought).'; my $match = RE_balanced( -parens => '(){}[]<>', -keep ); $string =~ s/${match}.*//; $1 and say \"^>$_^<\" for $string, $1; " >The use of parentheses < >(indicates that the (writer [considered] the {information}) less <imp +ortantalmost> an afterthought)<
Give a man a fish: <%-{-{-{-<
In reply to Re^2: bracket processing (updated)
by AnomalousMonk
in thread bracket processing
by rajaman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |