--- code/trunk/doc/html/pcrepattern.html 2010/01/06 10:26:55 487 +++ code/trunk/doc/html/pcrepattern.html 2010/01/11 15:29:42 488 @@ -239,7 +239,7 @@ \n linefeed (hex 0A) \r carriage return (hex 0D) \t tab (hex 09) - \ddd character with octal code ddd, or backreference + \ddd character with octal code ddd, or back reference \xhh character with hex code hh \x{hhh..} character with hex code hhh.. @@ -1157,9 +1157,9 @@ / ( a ) (?| x ( y ) z | (p (q) r) | (t) u (v) ) ( z ) /x # 1 2 2 3 2 3 4 -A backreference to a numbered subpattern uses the most recent value that is set -for that number by any subpattern. The following pattern matches "abcabc" or -"defdef": +A back reference to a numbered subpattern uses the most recent value that is +set for that number by any subpattern. The following pattern matches "abcabc" +or "defdef":
   /(?|(abc)|(def))\1/
 
@@ -1193,7 +1193,7 @@ In PCRE, a subpattern can be named in one of three ways: (?<name>...) or (?'name'...) as in Perl, or (?P<name>...) as in Python. References to capturing parentheses from other parts of the pattern, such as -backreferences, +back references, recursion, and conditions, @@ -1232,7 +1232,7 @@ matched. This saves searching to find which numbered subpattern it was.

-If you make a backreference to a non-unique named subpattern from elsewhere in +If you make a back reference to a non-unique named subpattern from elsewhere in the pattern, the one that corresponds to the first occurrence of the name is used. In the absence of duplicate numbers (see the previous section) this is the one with the lowest number. If you use a named reference in a condition @@ -1385,7 +1385,7 @@

However, there is one situation where the optimization cannot be used. When .* -is inside capturing parentheses that are the subject of a backreference +is inside capturing parentheses that are the subject of a back reference elsewhere in the pattern, a match at the start may fail where a later one succeeds. Consider, for example:

@@ -1616,6 +1616,9 @@
 "Comments"
 below) can be used.
 

+
+Recursive back references +

A back reference that occurs inside the parentheses to which it refers fails when the subpattern is first used, so, for example, (a\1) never matches. @@ -1630,6 +1633,13 @@ that the first iteration does not need to match the back reference. This can be done using alternation, as in the example above, or by a quantifier with a minimum of zero. +

+

+Back references of this type cause the group that they reference to be treated +as an +atomic group. +Once the whole group has been matched, a subsequent matching failure cannot +cause backtracking into the middle of the group.


ASSERTIONS

@@ -2386,9 +2396,9 @@


REVISION

-Last updated: 18 October 2009 +Last updated: 11 January 2010
-Copyright © 1997-2009 University of Cambridge. +Copyright © 1997-2010 University of Cambridge.

Return to the PCRE index page.