/[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 167 by ph10, Wed May 9 15:53:54 2007 UTC revision 171 by ph10, Mon Jun 4 14:28:58 2007 UTC
# Line 30  The remainder of this document discusses Line 30  The remainder of this document discusses
30  PCRE when its main matching function, \fBpcre_exec()\fP, is used.  PCRE when its main matching function, \fBpcre_exec()\fP, is used.
31  From release 6.0, PCRE offers a second matching function,  From release 6.0, PCRE offers a second matching function,
32  \fBpcre_dfa_exec()\fP, which matches using a different algorithm that is not  \fBpcre_dfa_exec()\fP, which matches using a different algorithm that is not
33  Perl-compatible. The advantages and disadvantages of the alternative function,  Perl-compatible. Some of the features discussed below are not available when
34  and how it differs from the normal function, are discussed in the  \fBpcre_dfa_exec()\fP is used. The advantages and disadvantages of the
35    alternative function, and how it differs from the normal function, are
36    discussed in the
37  .\" HREF  .\" HREF
38  \fBpcrematching\fP  \fBpcrematching\fP
39  .\"  .\"
# Line 239  meanings Line 241  meanings
241  .rs  .rs
242  .sp  .sp
243  The sequence \eg followed by a positive or negative number, optionally enclosed  The sequence \eg followed by a positive or negative number, optionally enclosed
244  in braces, is an absolute or relative back reference. Back references are  in braces, is an absolute or relative back reference. A named back reference
245  discussed  can be coded as \eg{name}. Back references are discussed
246  .\" HTML <a href="#backreferences">  .\" HTML <a href="#backreferences">
247  .\" </a>  .\" </a>
248  later,  later,
# Line 519  why the traditional escape sequences suc Line 521  why the traditional escape sequences suc
521  properties in PCRE.  properties in PCRE.
522  .  .
523  .  .
524    .\" HTML <a name="resetmatchstart"></a>
525    .SS "Resetting the match start"
526    .rs
527    .sp
528    The escape sequence \eK, which is a Perl 5.10 feature, causes any previously
529    matched characters not to be included in the final matched sequence. For
530    example, the pattern:
531    .sp
532      foo\eKbar
533    .sp
534    matches "foobar", but reports that it has matched "bar". This feature is
535    similar to a lookbehind assertion
536    .\" HTML <a href="#lookbehind">
537    .\" </a>
538    (described below).
539    .\"
540    However, in this case, the part of the subject before the real match does not
541    have to be of fixed length, as lookbehind assertions do. The use of \eK does
542    not interfere with the setting of
543    .\" HTML <a href="#subpattern">
544    .\" </a>
545    captured substrings.
546    .\"
547    For example, when the pattern
548    .sp
549      (foo)\eKbar
550    .sp
551    matches "foobar", the first substring is still set to "foo".
552    .
553    .
554  .\" HTML <a name="smallassertions"></a>  .\" HTML <a name="smallassertions"></a>
555  .SS "Simple assertions"  .SS "Simple assertions"
556  .rs  .rs
# Line 1293  back reference, the case of letters is r Line 1325  back reference, the case of letters is r
1325  matches "rah rah" and "RAH RAH", but not "RAH rah", even though the original  matches "rah rah" and "RAH RAH", but not "RAH rah", even though the original
1326  capturing subpattern is matched caselessly.  capturing subpattern is matched caselessly.
1327  .P  .P
1328  Back references to named subpatterns use the Perl syntax \ek<name> or \ek'name'  There are several different ways of writing back references to named
1329  or the Python syntax (?P=name). We could rewrite the above example in either of  subpatterns. The .NET syntax \ek{name} and the Perl syntax \ek<name> or
1330    \ek'name' are supported, as is the Python syntax (?P=name). Perl 5.10's unified
1331    back reference syntax, in which \eg can be used for both numeric and named
1332    references, is also supported. We could rewrite the above example in any of
1333  the following ways:  the following ways:
1334  .sp  .sp
1335    (?<p1>(?i)rah)\es+\ek<p1>    (?<p1>(?i)rah)\es+\ek<p1>
1336      (?'p1'(?i)rah)\es+\ek{p1}
1337    (?P<p1>(?i)rah)\es+(?P=p1)    (?P<p1>(?i)rah)\es+(?P=p1)
1338      (?<p1>(?i)rah)\es+\eg{p1}
1339  .sp  .sp
1340  A subpattern that is referenced by name may appear in the pattern before or  A subpattern that is referenced by name may appear in the pattern before or
1341  after the reference.  after the reference.
# Line 1421  lengths, but it is acceptable if rewritt Line 1458  lengths, but it is acceptable if rewritt
1458  .sp  .sp
1459    (?<=abc|abde)    (?<=abc|abde)
1460  .sp  .sp
1461    In some cases, the Perl 5.10 escape sequence \eK
1462    .\" HTML <a href="#resetmatchstart">
1463    .\" </a>
1464    (see above)
1465    .\"
1466    can be used instead of a lookbehind assertion; this is not restricted to a
1467    fixed-length.
1468    .P
1469  The implementation of lookbehind assertions is, for each alternative, to  The implementation of lookbehind assertions is, for each alternative, to
1470  temporarily move the current position back by the fixed length and then try to  temporarily move the current position back by the fixed length and then try to
1471  match. If there are insufficient characters before the current position, the  match. If there are insufficient characters before the current position, the
# Line 1853  Cambridge CB2 3QH, England. Line 1898  Cambridge CB2 3QH, England.
1898  .rs  .rs
1899  .sp  .sp
1900  .nf  .nf
1901  Last updated: 09 May 2007  Last updated: 29 May 2007
1902  Copyright (c) 1997-2007 University of Cambridge.  Copyright (c) 1997-2007 University of Cambridge.
1903  .fi  .fi

Legend:
Removed from v.167  
changed lines
  Added in v.171

  ViewVC Help
Powered by ViewVC 1.1.5