Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: bracket processing (updated)

by AnomalousMonk (Archbishop)
on Mar 31, 2020 at 05:48 UTC ( [id://11114827]=note: print w/replies, xml ) Need Help??


in reply to Re: bracket processing
in thread bracket processing

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:

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; "
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 => '(){}[]<>', -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:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^3: bracket processing
by haukex (Archbishop) on Mar 31, 2020 at 07:25 UTC
    I can only generate the given output when I add the -keep switch to the RE_balanced() call.

    What version are you using? From Regexp::Common::balanced:

    Since version 2013030901, $1 will always be set (to the entire matched substring), regardless whether {-keep} is used or not.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11114827]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2024-04-16 19:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found