/[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 231 by ph10, Tue Sep 11 11:15:33 2007 UTC revision 461 by ph10, Mon Oct 5 10:59:35 2009 UTC
# Line 17  DIFFERENCES BETWEEN PCRE AND PERL Line 17  DIFFERENCES BETWEEN PCRE AND PERL
17  </b><br>  </b><br>
18  <P>  <P>
19  This document describes the differences in the ways that PCRE and Perl handle  This document describes the differences in the ways that PCRE and Perl handle
20  regular expressions. The differences described here are mainly with respect to  regular expressions. The differences described here are with respect to Perl
21  Perl 5.8, though PCRE versions 7.0 and later contain some features that are  5.10.
 expected to be in the forthcoming Perl 5.10.  
22  </P>  </P>
23  <P>  <P>
24  1. PCRE has only a subset of Perl's UTF-8 and Unicode support. Details of what  1. PCRE has only a subset of Perl's UTF-8 and Unicode support. Details of what
# Line 59  encountered by PCRE, an error is generat Line 58  encountered by PCRE, an error is generat
58  built with Unicode character property support. The properties that can be  built with Unicode character property support. The properties that can be
59  tested with \p and \P are limited to the general category properties such as  tested with \p and \P are limited to the general category properties such as
60  Lu and Nd, script names such as Greek or Han, and the derived properties Any  Lu and Nd, script names such as Greek or Han, and the derived properties Any
61  and L&.  and L&. PCRE does support the Cs (surrogate) property, which Perl does not; the
62    Perl documentation says "Because Perl hides the need for the user to understand
63    the internal representation of Unicode characters, there is no need to
64    implement the somewhat messy concept of surrogates."
65  </P>  </P>
66  <P>  <P>
67  7. PCRE does support the \Q...\E escape for quoting substrings. Characters in  7. PCRE does support the \Q...\E escape for quoting substrings. Characters in
# Line 79  The \Q...\E sequence is recognized both Line 81  The \Q...\E sequence is recognized both
81  <P>  <P>
82  8. Fairly obviously, PCRE does not support the (?{code}) and (??{code})  8. Fairly obviously, PCRE does not support the (?{code}) and (??{code})
83  constructions. However, there is support for recursive patterns. This is not  constructions. However, there is support for recursive patterns. This is not
84  available in Perl 5.8, but will be in Perl 5.10. Also, the PCRE "callout"  available in Perl 5.8, but it is in Perl 5.10. Also, the PCRE "callout"
85  feature allows an external function to be called during pattern matching. See  feature allows an external function to be called during pattern matching. See
86  the  the
87  <a href="pcrecallout.html"><b>pcrecallout</b></a>  <a href="pcrecallout.html"><b>pcrecallout</b></a>
# Line 87  documentation for details. Line 89  documentation for details.
89  </P>  </P>
90  <P>  <P>
91  9. Subpatterns that are called recursively or as "subroutines" are always  9. Subpatterns that are called recursively or as "subroutines" are always
92  treated as atomic groups in PCRE. This is like Python, but unlike Perl.  treated as atomic groups in PCRE. This is like Python, but unlike Perl. There
93    is a discussion of an example that explains this in more detail in the
94    <a href="pcrepattern.html#recursiondifference">section on recursion differences from Perl</a>
95    in the
96    <a href="pcrepattern.html"><b>pcrepattern</b></a>
97    page.
98  </P>  </P>
99  <P>  <P>
100  10. There are some differences that are concerned with the settings of captured  10. There are some differences that are concerned with the settings of captured
# Line 97  the pattern /^(a(b)?)+$/ in Perl leaves Line 104  the pattern /^(a(b)?)+$/ in Perl leaves
104  <P>  <P>
105  11. PCRE does support Perl 5.10's backtracking verbs (*ACCEPT), (*FAIL), (*F),  11. PCRE does support Perl 5.10's backtracking verbs (*ACCEPT), (*FAIL), (*F),
106  (*COMMIT), (*PRUNE), (*SKIP), and (*THEN), but only in the forms without an  (*COMMIT), (*PRUNE), (*SKIP), and (*THEN), but only in the forms without an
107  argument. PCRE does not support (*MARK). If (*ACCEPT) is within capturing  argument. PCRE does not support (*MARK).
108  parentheses, PCRE does not set that capture group; this is different to Perl.  </P>
109    <P>
110    12. PCRE's handling of duplicate subpattern numbers and duplicate subpattern
111    names is not as general as Perl's. This is a consequence of the fact the PCRE
112    works internally just with numbers, using an external table to translate
113    between numbers and names. In particular, a pattern such as (?|(?&#60;a&#62;A)|(?&#60;b)B),
114    where the two capturing parentheses have the same number but different names,
115    is not supported, and causes an error at compile time. If it were allowed, it
116    would not be possible to distinguish which parentheses matched, because both
117    names map to capturing subpattern number 1. To avoid this confusing situation,
118    an error is given at compile time.
119  </P>  </P>
120  <P>  <P>
121  12. PCRE provides some extensions to the Perl regular expression facilities.  13. PCRE provides some extensions to the Perl regular expression facilities.
122  Perl 5.10 will include new features that are not in earlier versions, some of  Perl 5.10 includes new features that are not in earlier versions of Perl, some
123  which (such as named parentheses) have been in PCRE for some time. This list is  of which (such as named parentheses) have been in PCRE for some time. This list
124  with respect to Perl 5.10:  is with respect to Perl 5.10:
125  <br>  <br>
126  <br>  <br>
127  (a) Although lookbehind assertions must match fixed length strings, each  (a) Although lookbehind assertions in PCRE must match fixed length strings,
128  alternative branch of a lookbehind assertion can match a different length of  each alternative branch of a lookbehind assertion can match a different length
129  string. Perl requires them all to have the same length.  of string. Perl requires them all to have the same length.
130  <br>  <br>
131  <br>  <br>
132  (b) If PCRE_DOLLAR_ENDONLY is set and PCRE_MULTILINE is not set, the $  (b) If PCRE_DOLLAR_ENDONLY is set and PCRE_MULTILINE is not set, the $
# Line 130  question mark they are. Line 147  question mark they are.
147  only at the first matching position in the subject string.  only at the first matching position in the subject string.
148  <br>  <br>
149  <br>  <br>
150  (f) The PCRE_NOTBOL, PCRE_NOTEOL, PCRE_NOTEMPTY, and PCRE_NO_AUTO_CAPTURE  (f) The PCRE_NOTBOL, PCRE_NOTEOL, PCRE_NOTEMPTY, PCRE_NOTEMPTY_ATSTART, and
151  options for <b>pcre_exec()</b> have no Perl equivalents.  PCRE_NO_AUTO_CAPTURE options for <b>pcre_exec()</b> have no Perl equivalents.
152  <br>  <br>
153  <br>  <br>
154  (g) The \R escape sequence can be restricted to match only CR, LF, or CRLF  (g) The \R escape sequence can be restricted to match only CR, LF, or CRLF
# Line 170  Cambridge CB2 3QH, England. Line 187  Cambridge CB2 3QH, England.
187  REVISION  REVISION
188  </b><br>  </b><br>
189  <P>  <P>
190  Last updated: 11 September 2007  Last updated: 04 October 2009
191  <br>  <br>
192  Copyright &copy; 1997-2007 University of Cambridge.  Copyright &copy; 1997-2009 University of Cambridge.
193  <br>  <br>
194  <p>  <p>
195  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.231  
changed lines
  Added in v.461

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12