Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Regex for outside of brackets

by atcroft (Abbot)
on Jul 13, 2018 at 14:37 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1218448]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-24 03:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found