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 mainly with respect to |
21 |
Perl 5.8, though PCRE version 7.0 contains some features that are expected to |
Perl 5.8, though PCRE versions 7.0 and later contain some features that are |
22 |
be in the forthcoming Perl 5.10. |
expected to be in the forthcoming Perl 5.10. |
23 |
</P> |
</P> |
24 |
<P> |
<P> |
25 |
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 |
95 |
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". |
96 |
</P> |
</P> |
97 |
<P> |
<P> |
98 |
11. PCRE provides some extensions to the Perl regular expression facilities. |
11. PCRE does support Perl 5.10's backtracking verbs (*ACCEPT), (*FAIL), (*F), |
99 |
|
(*COMMIT), (*PRUNE), (*SKIP), and (*THEN), but only in the forms without an |
100 |
|
argument. PCRE does not support (*MARK). If (*ACCEPT) is within capturing |
101 |
|
parentheses, PCRE does not set that capture group; this is different to Perl. |
102 |
|
</P> |
103 |
|
<P> |
104 |
|
12. PCRE provides some extensions to the Perl regular expression facilities. |
105 |
Perl 5.10 will include new features that are not in earlier versions, some of |
Perl 5.10 will include new features that are not in earlier versions, some of |
106 |
which (such as named parentheses) have been in PCRE for some time. This list is |
which (such as named parentheses) have been in PCRE for some time. This list is |
107 |
with respect to Perl 5.10: |
with respect to Perl 5.10: |
117 |
<br> |
<br> |
118 |
<br> |
<br> |
119 |
(c) If PCRE_EXTRA is set, a backslash followed by a letter with no special |
(c) If PCRE_EXTRA is set, a backslash followed by a letter with no special |
120 |
meaning is faulted. Otherwise, like Perl, the backslash is ignored. (Perl can |
meaning is faulted. Otherwise, like Perl, the backslash is quietly ignored. |
121 |
be made to issue a warning.) |
(Perl can be made to issue a warning.) |
122 |
<br> |
<br> |
123 |
<br> |
<br> |
124 |
(d) If PCRE_UNGREEDY is set, the greediness of the repetition quantifiers is |
(d) If PCRE_UNGREEDY is set, the greediness of the repetition quantifiers is |
134 |
options for <b>pcre_exec()</b> have no Perl equivalents. |
options for <b>pcre_exec()</b> have no Perl equivalents. |
135 |
<br> |
<br> |
136 |
<br> |
<br> |
137 |
(g) The callout facility is PCRE-specific. |
(g) The \R escape sequence can be restricted to match only CR, LF, or CRLF |
138 |
|
by the PCRE_BSR_ANYCRLF option. |
139 |
|
<br> |
140 |
<br> |
<br> |
141 |
|
(h) The callout facility is PCRE-specific. |
142 |
<br> |
<br> |
|
(h) The partial matching facility is PCRE-specific. |
|
143 |
<br> |
<br> |
144 |
|
(i) The partial matching facility is PCRE-specific. |
145 |
<br> |
<br> |
146 |
(i) Patterns compiled by PCRE can be saved and re-used at a later time, even on |
<br> |
147 |
|
(j) Patterns compiled by PCRE can be saved and re-used at a later time, even on |
148 |
different hosts that have the other endianness. |
different hosts that have the other endianness. |
149 |
<br> |
<br> |
150 |
<br> |
<br> |
151 |
(j) The alternative matching function (<b>pcre_dfa_exec()</b>) matches in a |
(k) The alternative matching function (<b>pcre_dfa_exec()</b>) matches in a |
152 |
different way and is not Perl-compatible. |
different way and is not Perl-compatible. |
153 |
|
<br> |
154 |
|
<br> |
155 |
|
(l) PCRE recognizes some special sequences such as (*CR) at the start of |
156 |
|
a pattern that set overall options that cannot be changed within the pattern. |
157 |
</P> |
</P> |
158 |
|
<br><b> |
159 |
|
AUTHOR |
160 |
|
</b><br> |
161 |
<P> |
<P> |
162 |
Last updated: 28 November 2006 |
Philip Hazel |
163 |
|
<br> |
164 |
|
University Computing Service |
165 |
|
<br> |
166 |
|
Cambridge CB2 3QH, England. |
167 |
|
<br> |
168 |
|
</P> |
169 |
|
<br><b> |
170 |
|
REVISION |
171 |
|
</b><br> |
172 |
|
<P> |
173 |
|
Last updated: 11 September 2007 |
174 |
|
<br> |
175 |
|
Copyright © 1997-2007 University of Cambridge. |
176 |
<br> |
<br> |
|
Copyright © 1997-2006 University of Cambridge. |
|
177 |
<p> |
<p> |
178 |
Return to the <a href="index.html">PCRE index page</a>. |
Return to the <a href="index.html">PCRE index page</a>. |
179 |
</p> |
</p> |