/[pcre]/code/trunk/doc/html/pcrepattern.html
ViewVC logotype

Diff of /code/trunk/doc/html/pcrepattern.html

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 487 by ph10, Mon Oct 19 14:38:48 2009 UTC revision 488 by ph10, Mon Jan 11 15:29:42 2010 UTC
# Line 239  one of the following escape sequences th Line 239  one of the following escape sequences th
239    \n        linefeed (hex 0A)    \n        linefeed (hex 0A)
240    \r        carriage return (hex 0D)    \r        carriage return (hex 0D)
241    \t        tab (hex 09)    \t        tab (hex 09)
242    \ddd      character with octal code ddd, or backreference    \ddd      character with octal code ddd, or back reference
243    \xhh      character with hex code hh    \xhh      character with hex code hh
244    \x{hhh..} character with hex code hhh..    \x{hhh..} character with hex code hhh..
245  </pre>  </pre>
# Line 1157  stored. Line 1157  stored.
1157    / ( a )  (?| x ( y ) z | (p (q) r) | (t) u (v) ) ( z ) /x    / ( a )  (?| x ( y ) z | (p (q) r) | (t) u (v) ) ( z ) /x
1158    # 1            2         2  3        2     3     4    # 1            2         2  3        2     3     4
1159  </pre>  </pre>
1160  A backreference to a numbered subpattern uses the most recent value that is set  A back reference to a numbered subpattern uses the most recent value that is
1161  for that number by any subpattern. The following pattern matches "abcabc" or  set for that number by any subpattern. The following pattern matches "abcabc"
1162  "defdef":  or "defdef":
1163  <pre>  <pre>
1164    /(?|(abc)|(def))\1/    /(?|(abc)|(def))\1/
1165  </pre>  </pre>
# Line 1193  have different names, but PCRE does not. Line 1193  have different names, but PCRE does not.
1193  In PCRE, a subpattern can be named in one of three ways: (?&#60;name&#62;...) or  In PCRE, a subpattern can be named in one of three ways: (?&#60;name&#62;...) or
1194  (?'name'...) as in Perl, or (?P&#60;name&#62;...) as in Python. References to capturing  (?'name'...) as in Perl, or (?P&#60;name&#62;...) as in Python. References to capturing
1195  parentheses from other parts of the pattern, such as  parentheses from other parts of the pattern, such as
1196  <a href="#backreferences">backreferences,</a>  <a href="#backreferences">back references,</a>
1197  <a href="#recursion">recursion,</a>  <a href="#recursion">recursion,</a>
1198  and  and
1199  <a href="#conditions">conditions,</a>  <a href="#conditions">conditions,</a>
# Line 1232  for the first (and in this example, the Line 1232  for the first (and in this example, the
1232  matched. This saves searching to find which numbered subpattern it was.  matched. This saves searching to find which numbered subpattern it was.
1233  </P>  </P>
1234  <P>  <P>
1235  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
1236  the pattern, the one that corresponds to the first occurrence of the name is  the pattern, the one that corresponds to the first occurrence of the name is
1237  used. In the absence of duplicate numbers (see the previous section) this is  used. In the absence of duplicate numbers (see the previous section) this is
1238  the one with the lowest number. If you use a named reference in a condition  the one with the lowest number. If you use a named reference in a condition
# Line 1385  alternatively using ^ to indicate anchor Line 1385  alternatively using ^ to indicate anchor
1385  </P>  </P>
1386  <P>  <P>
1387  However, there is one situation where the optimization cannot be used. When .*  However, there is one situation where the optimization cannot be used. When .*
1388  is inside capturing parentheses that are the subject of a backreference  is inside capturing parentheses that are the subject of a back reference
1389  elsewhere in the pattern, a match at the start may fail where a later one  elsewhere in the pattern, a match at the start may fail where a later one
1390  succeeds. Consider, for example:  succeeds. Consider, for example:
1391  <pre>  <pre>
# Line 1616  whitespace. Otherwise, the \g{ syntax or Line 1616  whitespace. Otherwise, the \g{ syntax or
1616  <a href="#comments">"Comments"</a>  <a href="#comments">"Comments"</a>
1617  below) can be used.  below) can be used.
1618  </P>  </P>
1619    <br><b>
1620    Recursive back references
1621    </b><br>
1622  <P>  <P>
1623  A back reference that occurs inside the parentheses to which it refers fails  A back reference that occurs inside the parentheses to which it refers fails
1624  when the subpattern is first used, so, for example, (a\1) never matches.  when the subpattern is first used, so, for example, (a\1) never matches.
# Line 1630  to the previous iteration. In order for Line 1633  to the previous iteration. In order for
1633  that the first iteration does not need to match the back reference. This can be  that the first iteration does not need to match the back reference. This can be
1634  done using alternation, as in the example above, or by a quantifier with a  done using alternation, as in the example above, or by a quantifier with a
1635  minimum of zero.  minimum of zero.
1636    </P>
1637    <P>
1638    Back references of this type cause the group that they reference to be treated
1639    as an
1640    <a href="#atomicgroup">atomic group.</a>
1641    Once the whole group has been matched, a subsequent matching failure cannot
1642    cause backtracking into the middle of the group.
1643  <a name="bigassertions"></a></P>  <a name="bigassertions"></a></P>
1644  <br><a name="SEC18" href="#TOC1">ASSERTIONS</a><br>  <br><a name="SEC18" href="#TOC1">ASSERTIONS</a><br>
1645  <P>  <P>
# Line 2386  Cambridge CB2 3QH, England. Line 2396  Cambridge CB2 3QH, England.
2396  </P>  </P>
2397  <br><a name="SEC28" href="#TOC1">REVISION</a><br>  <br><a name="SEC28" href="#TOC1">REVISION</a><br>
2398  <P>  <P>
2399  Last updated: 18 October 2009  Last updated: 11 January 2010
2400  <br>  <br>
2401  Copyright &copy; 1997-2009 University of Cambridge.  Copyright &copy; 1997-2010 University of Cambridge.
2402  <br>  <br>
2403  <p>  <p>
2404  Return to the <a href="index.html">PCRE index page</a>.  Return to the <a href="index.html">PCRE index page</a>.

Legend:
Removed from v.487  
changed lines
  Added in v.488

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12