Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^3: regex anchoring issue

by kcott (Abbot)
on Feb 16, 2013 at 05:58 UTC ( #1019013=note: print w/ replies, xml ) Need Help??


in reply to Re^2: regex anchoring issue
in thread regex anchoring issue

Wrapping regexp alternations in (?>...) is something I do by default. While there may be rare cases where this might be problematical, I haven't encountered any: it's something that doesn't hurt and, indeed, often helps.

This usage is based on a "Perl Best Practices" guideline: Backtracking (page 269). It's summarised on page 271 as:

... rewrite any instance of:

X | Y

as:

(?> X | Y )

While I'm not a slave to all "Perl Best Practices" guidelines, this is one I have found to be useful.

Update: s/have encountered/haven't encountered/

-- Ken


Comment on Re^3: regex anchoring issue
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2015-07-06 03:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (69 votes), past polls