Sorry not to reply sooner, but I've been busy.

Backtracking is simply what the regex engine does when it can't make a match, but still has other items to consider. A simple example is if you want to match /(this|that).*(these|those)/, the engine first looks for a 't', then an 'h', etc. If it finds an 'n' after 'thi', then it backtracks to see if it can match 'that'. In this case, though it might not be nice to look at, breaking it out into four regexes (/this.*these/, /this.*those/, etc) turns out to be more efficient than the alternation version because if it fails to find 'this', for example, it simply fails without trying additional matches.

Anyway, (?>...) is a way to cut off backtracking for hairy regexes. It can make parsing a lot faster.


In reply to Re^2: Recursive Regex: Response by furry_marmot
in thread Parsing using Regex and Lookahead by deMize

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.