http://www.perlmonks.org?node_id=1019013


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