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

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

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

revision 653 by ph10, Wed Nov 24 17:39:25 2010 UTC revision 654 by ph10, Tue Aug 2 11:00:40 2011 UTC
# Line 29  in the main Line 29  in the main
29  page.  page.
30  </P>  </P>
31  <P>  <P>
32  2. PCRE does not allow repeat quantifiers on lookahead assertions. Perl permits  2. PCRE allows repeat quantifiers only on parenthesized assertions, but they do
33  them, but they do not mean what you might think. For example, (?!a){3} does  not mean what you might think. For example, (?!a){3} does not assert that the
34  not assert that the next three characters are not "a". It just asserts that the  next three characters are not "a". It just asserts that the next character is
35  next character is not "a" three times.  not "a" three times (in principle: PCRE optimizes this to run the assertion
36    just once). Perl allows repeat quantifiers on other assertions such as \b, but
37    these do not seem to have any use.
38  </P>  </P>
39  <P>  <P>
40  3. Capturing subpatterns that occur inside negative lookahead assertions are  3. Capturing subpatterns that occur inside negative lookahead assertions are
# Line 49  represent a binary zero. Line 51  represent a binary zero.
51  </P>  </P>
52  <P>  <P>
53  5. The following Perl escape sequences are not supported: \l, \u, \L,  5. The following Perl escape sequences are not supported: \l, \u, \L,
54  \U, and \N. In fact these are implemented by Perl's general string-handling  \U, and \N when followed by a character name or Unicode value. (\N on its
55  and are not part of its pattern matching engine. If any of these are  own, matching a non-newline character, is supported.) In fact these are
56  encountered by PCRE, an error is generated.  implemented by Perl's general string-handling and are not part of its pattern
57    matching engine. If any of these are encountered by PCRE, an error is
58    generated.
59  </P>  </P>
60  <P>  <P>
61  6. The Perl escape sequences \p, \P, and \X are supported only if PCRE is  6. The Perl escape sequences \p, \P, and \X are supported only if PCRE is
# Line 64  the internal representation of Unicode c Line 68  the internal representation of Unicode c
68  implement the somewhat messy concept of surrogates."  implement the somewhat messy concept of surrogates."
69  </P>  </P>
70  <P>  <P>
71  7. PCRE does support the \Q...\E escape for quoting substrings. Characters in  7. PCRE implements a simpler version of \X than Perl, which changed to make
72    \X match what Unicode calls an "extended grapheme cluster". This is more
73    complicated than an extended Unicode sequence, which is what PCRE matches.
74    </P>
75    <P>
76    8. PCRE does support the \Q...\E escape for quoting substrings. Characters in
77  between are treated as literals. This is slightly different from Perl in that $  between are treated as literals. This is slightly different from Perl in that $
78  and @ are also handled as literals inside the quotes. In Perl, they cause  and @ are also handled as literals inside the quotes. In Perl, they cause
79  variable interpolation (but of course PCRE does not have variables). Note the  variable interpolation (but of course PCRE does not have variables). Note the
# Line 79  following examples: Line 88  following examples:
88  The \Q...\E sequence is recognized both inside and outside character classes.  The \Q...\E sequence is recognized both inside and outside character classes.
89  </P>  </P>
90  <P>  <P>
91  8. Fairly obviously, PCRE does not support the (?{code}) and (??{code})  9. Fairly obviously, PCRE does not support the (?{code}) and (??{code})
92  constructions. However, there is support for recursive patterns. This is not  constructions. However, there is support for recursive patterns. This is not
93  available in Perl 5.8, but it is in Perl 5.10. Also, the PCRE "callout"  available in Perl 5.8, but it is in Perl 5.10. Also, the PCRE "callout"
94  feature allows an external function to be called during pattern matching. See  feature allows an external function to be called during pattern matching. See
# Line 88  the Line 97  the
97  documentation for details.  documentation for details.
98  </P>  </P>
99  <P>  <P>
100  9. Subpatterns that are called recursively or as "subroutines" are always  10. Subpatterns that are called recursively or as "subroutines" are always
101  treated as atomic groups in PCRE. This is like Python, but unlike Perl. There  treated as atomic groups in PCRE. This is like Python, but unlike Perl. There
102  is a discussion of an example that explains this in more detail in the  is a discussion of an example that explains this in more detail in the
103  <a href="pcrepattern.html#recursiondifference">section on recursion differences from Perl</a>  <a href="pcrepattern.html#recursiondifference">section on recursion differences from Perl</a>
# Line 97  in the Line 106  in the
106  page.  page.
107  </P>  </P>
108  <P>  <P>
109  10. There are some differences that are concerned with the settings of captured  11. There are some differences that are concerned with the settings of captured
110  strings when part of a pattern is repeated. For example, matching "aba" against  strings when part of a pattern is repeated. For example, matching "aba" against
111  the pattern /^(a(b)?)+$/ in Perl leaves $2 unset, but in PCRE it is set to "b".  the pattern /^(a(b)?)+$/ in Perl leaves $2 unset, but in PCRE it is set to "b".
112  </P>  </P>
113  <P>  <P>
114  11. PCRE's handling of duplicate subpattern numbers and duplicate subpattern  12. PCRE's handling of duplicate subpattern numbers and duplicate subpattern
115  names is not as general as Perl's. This is a consequence of the fact the PCRE  names is not as general as Perl's. This is a consequence of the fact the PCRE
116  works internally just with numbers, using an external table to translate  works internally just with numbers, using an external table to translate
117  between numbers and names. In particular, a pattern such as (?|(?&#60;a&#62;A)|(?&#60;b)B),  between numbers and names. In particular, a pattern such as (?|(?&#60;a&#62;A)|(?&#60;b)B),
# Line 113  names map to capturing subpattern number Line 122  names map to capturing subpattern number
122  an error is given at compile time.  an error is given at compile time.
123  </P>  </P>
124  <P>  <P>
125  12. Perl recognizes comments in some places that PCRE doesn't, for example,  13. Perl recognizes comments in some places that PCRE does not, for example,
126  between the ( and ? at the start of a subpattern.  between the ( and ? at the start of a subpattern. If the /x modifier is set,
127    Perl allows whitespace between ( and ? but PCRE never does, even if the
128    PCRE_EXTENDED option is set.
129  </P>  </P>
130  <P>  <P>
131  13. PCRE provides some extensions to the Perl regular expression facilities.  14. PCRE provides some extensions to the Perl regular expression facilities.
132  Perl 5.10 includes new features that are not in earlier versions of Perl, some  Perl 5.10 includes new features that are not in earlier versions of Perl, some
133  of which (such as named parentheses) have been in PCRE for some time. This list  of which (such as named parentheses) have been in PCRE for some time. This list
134  is with respect to Perl 5.10:  is with respect to Perl 5.10:
# Line 186  Cambridge CB2 3QH, England. Line 197  Cambridge CB2 3QH, England.
197  REVISION  REVISION
198  </b><br>  </b><br>
199  <P>  <P>
200  Last updated: 31 October 2010  Last updated: 24 July 2011
201  <br>  <br>
202  Copyright &copy; 1997-2010 University of Cambridge.  Copyright &copy; 1997-2011 University of Cambridge.
203  <br>  <br>
204  <p>  <p>
205  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.653  
changed lines
  Added in v.654

  ViewVC Help
Powered by ViewVC 1.1.5