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

Re: Regex code block executes twice per match using look-arounds

by ikegami (Patriarch)
on Jul 12, 2007 at 17:36 UTC ( [id://626287]=note: print w/replies, xml ) Need Help??


in reply to Regex code block executes twice per match using look-arounds

A alternate solution, just for fun.

use strict; use warnings; my $paren_grp_re = qr/ \( [^ ) ]* \) /x; my $square_grp_re = qr/ \[ [^ \] ]* \] /x; my $curly_grp_re = qr/ { [^ } ]* } /x; my $angle_grp_re = qr/ < [^ > ]* > /x; my $string = '<x1>[x2]{x3}(x4)'; print "Before: $string\n"; $string = join '+', map / $paren_grp_re | $square_grp_re | $curly_grp_re | $angle_grp_re | [^\(\[\{\<] /xg, $string; print "After: $string\n";

Doesn't support nesting.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-04-23 23:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found