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

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

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

revision 469 by ph10, Mon Oct 19 14:38:48 2009 UTC revision 488 by ph10, Mon Jan 11 15:29:42 2010 UTC
# Line 217  one of the following escape sequences th Line 217  one of the following escape sequences th
217    \en        linefeed (hex 0A)    \en        linefeed (hex 0A)
218    \er        carriage return (hex 0D)    \er        carriage return (hex 0D)
219    \et        tab (hex 09)    \et        tab (hex 09)
220    \eddd      character with octal code ddd, or backreference    \eddd      character with octal code ddd, or back reference
221    \exhh      character with hex code hh    \exhh      character with hex code hh
222    \ex{hhh..} character with hex code hhh..    \ex{hhh..} character with hex code hhh..
223  .sp  .sp
# Line 1163  stored. Line 1163  stored.
1163    / ( a )  (?| x ( y ) z | (p (q) r) | (t) u (v) ) ( z ) /x    / ( a )  (?| x ( y ) z | (p (q) r) | (t) u (v) ) ( z ) /x
1164    # 1            2         2  3        2     3     4    # 1            2         2  3        2     3     4
1165  .sp  .sp
1166  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
1167  for that number by any subpattern. The following pattern matches "abcabc" or  set for that number by any subpattern. The following pattern matches "abcabc"
1168  "defdef":  or "defdef":
1169  .sp  .sp
1170    /(?|(abc)|(def))\e1/    /(?|(abc)|(def))\e1/
1171  .sp  .sp
# Line 1204  In PCRE, a subpattern can be named in on Line 1204  In PCRE, a subpattern can be named in on
1204  parentheses from other parts of the pattern, such as  parentheses from other parts of the pattern, such as
1205  .\" HTML <a href="#backreferences">  .\" HTML <a href="#backreferences">
1206  .\" </a>  .\" </a>
1207  backreferences,  back references,
1208  .\"  .\"
1209  .\" HTML <a href="#recursion">  .\" HTML <a href="#recursion">
1210  .\" </a>  .\" </a>
# Line 1246  The convenience function for extracting Line 1246  The convenience function for extracting
1246  for the first (and in this example, the only) subpattern of that name that  for the first (and in this example, the only) subpattern of that name that
1247  matched. This saves searching to find which numbered subpattern it was.  matched. This saves searching to find which numbered subpattern it was.
1248  .P  .P
1249  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
1250  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
1251  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
1252  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 1399  worth setting PCRE_DOTALL in order to ob Line 1399  worth setting PCRE_DOTALL in order to ob
1399  alternatively using ^ to indicate anchoring explicitly.  alternatively using ^ to indicate anchoring explicitly.
1400  .P  .P
1401  However, there is one situation where the optimization cannot be used. When .*  However, there is one situation where the optimization cannot be used. When .*
1402  is inside capturing parentheses that are the subject of a backreference  is inside capturing parentheses that are the subject of a back reference
1403  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
1404  succeeds. Consider, for example:  succeeds. Consider, for example:
1405  .sp  .sp
# Line 1628  whitespace. Otherwise, the \eg{ syntax o Line 1628  whitespace. Otherwise, the \eg{ syntax o
1628  "Comments"  "Comments"
1629  .\"  .\"
1630  below) can be used.  below) can be used.
1631  .P  .
1632    .SS "Recursive back references"
1633    .rs
1634    .sp
1635  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
1636  when the subpattern is first used, so, for example, (a\e1) never matches.  when the subpattern is first used, so, for example, (a\e1) never matches.
1637  However, such references can be useful inside repeated subpatterns. For  However, such references can be useful inside repeated subpatterns. For
# Line 1642  to the previous iteration. In order for Line 1645  to the previous iteration. In order for
1645  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
1646  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
1647  minimum of zero.  minimum of zero.
1648    .P
1649    Back references of this type cause the group that they reference to be treated
1650    as an
1651    .\" HTML <a href="#atomicgroup">
1652    .\" </a>
1653    atomic group.
1654    .\"
1655    Once the whole group has been matched, a subsequent matching failure cannot
1656    cause backtracking into the middle of the group.
1657  .  .
1658  .  .
1659  .\" HTML <a name="bigassertions"></a>  .\" HTML <a name="bigassertions"></a>
# Line 2415  Cambridge CB2 3QH, England. Line 2427  Cambridge CB2 3QH, England.
2427  .rs  .rs
2428  .sp  .sp
2429  .nf  .nf
2430  Last updated: 18 October 2009  Last updated: 11 January 2010
2431  Copyright (c) 1997-2009 University of Cambridge.  Copyright (c) 1997-2010 University of Cambridge.
2432  .fi  .fi

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

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12