Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: regex anchoring issue

by smls (Friar)
on Feb 15, 2013 at 11:23 UTC ( #1018879=note: print w/replies, xml ) Need Help??


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

Why do you place the regex in a (?>...) non-backtracking group?

Replies are listed 'Best First'.
Re^3: regex anchoring issue
by kcott (Chancellor) on Feb 16, 2013 at 05:58 UTC

    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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1018879]
help
Chatterbox?
[stonecolddevin]: https://open. spotify.com/track/ 0UVM9trirBK5s1xBwL oVhZ rather
[Corion]: Sadly I must go to bed now :-| See y'all!
[erix]: I really loved/love this "Recorded Live" record, 1973 (yes, I'm that old)
[stonecolddevin]: goodnight Corion
[erix]: cya Corion :)
[stevieb]: Joan Jett, Hendrix, Neil Young, Dave Keuning (The Killers)... I have my mind elsewhere so I'm limited in my capacity to think about this righ tnow ;)
[erix]: another blues with Big Red :)
[stonecolddevin]: I will say John Mayer is an excellent guitarist, I don't like his music but he's pretty damn good
[erix]: scd: maybe you like John Mayall better :)
[erix]: (mayall = british blues)

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2017-06-22 21:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (531 votes). Check out past polls.