Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Regex for outside of brackets

by atcroft (Abbot)
on Jul 13, 2018 at 14:37 UTC ( #1218448=note: print w/replies, xml ) Need Help??


in reply to Regex for outside of brackets

I think this may be close to what you are asking, and only uses a module shipped in core, Text::Balanced:

$ perl -MData::Dumper -MText::Balanced -le ' use 5.010; $Data::Dumper::Deepcopy = $Data::Dumper::Sortkeys = 1; my $c = q{This is outside (This is inside).}; my %found; ( $found{prefix}, $found{bracketed}, $found{postfix}, ) = Text::Balanced::extract_multiple($c, [ \&Text::Balanced::extract_bracketed, ], ); say Data::Dumper->Dump( [ \%found, ], [ qw( *f ) ] ); ' %f = ( 'bracketed' => '(This is inside)', 'postfix' => '.', 'prefix' => 'This is outside ' );

Hope that helps.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2020-09-29 11:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If at first I donít succeed, I Ö










    Results (146 votes). Check out past polls.

    Notices?