ViewVC logotype

Contents of /code/trunk/doc/pcre.3

Parent Directory Parent Directory | Revision Log Revision Log

Revision 71 - (show annotations)
Sat Feb 24 21:40:24 2007 UTC (14 years, 2 months ago) by nigel
File size: 6924 byte(s)
Error occurred while calculating annotation data.
Load pcre-4.4 into code/trunk.
1 .TH PCRE 3
3 PCRE - Perl-compatible regular expressions
5 .rs
6 .sp
7 The PCRE library is a set of functions that implement regular expression
8 pattern matching using the same syntax and semantics as Perl, with just a few
9 differences. The current implementation of PCRE (release 4.x) corresponds
10 approximately with Perl 5.8, including support for UTF-8 encoded strings.
11 However, this support has to be explicitly enabled; it is not the default.
13 PCRE is written in C and released as a C library. However, a number of people
14 have written wrappers and interfaces of various kinds. A C++ class is included
15 in these contributions, which can be found in the \fIContrib\fR directory at
16 the primary FTP site, which is:
18 .\" HTML <a href="ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre">
19 .\" </a>
20 ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre
22 Details of exactly which Perl regular expression features are and are not
23 supported by PCRE are given in separate documents. See the
24 .\" HREF
25 \fBpcrepattern\fR
26 .\"
27 and
28 .\" HREF
29 \fBpcrecompat\fR
30 .\"
31 pages.
33 Some features of PCRE can be included, excluded, or changed when the library is
34 built. The
35 .\" HREF
36 \fBpcre_config()\fR
37 .\"
38 function makes it possible for a client to discover which features are
39 available. Documentation about building PCRE for various operating systems can
40 be found in the \fBREADME\fR file in the source distribution.
43 .rs
44 .sp
45 The user documentation for PCRE has been split up into a number of different
46 sections. In the "man" format, each of these is a separate "man page". In the
47 HTML format, each is a separate page, linked from the index page. In the plain
48 text format, all the sections are concatenated, for ease of searching. The
49 sections are as follows:
51 pcre this document
52 pcreapi details of PCRE's native API
53 pcrebuild options for building PCRE
54 pcrecallout details of the callout feature
55 pcrecompat discussion of Perl compatibility
56 pcregrep description of the \fBpcregrep\fR command
57 pcrepattern syntax and semantics of supported
58 regular expressions
59 pcreperform discussion of performance issues
60 pcreposix the POSIX-compatible API
61 pcresample discussion of the sample program
62 pcretest the \fBpcretest\fR testing command
64 In addition, in the "man" and HTML formats, there is a short page for each
65 library function, listing its arguments and results.
68 .rs
69 .sp
70 There are some size limitations in PCRE but it is hoped that they will never in
71 practice be relevant.
73 The maximum length of a compiled pattern is 65539 (sic) bytes if PCRE is
74 compiled with the default internal linkage size of 2. If you want to process
75 regular expressions that are truly enormous, you can compile PCRE with an
76 internal linkage size of 3 or 4 (see the \fBREADME\fR file in the source
77 distribution and the
78 .\" HREF
79 \fBpcrebuild\fR
80 .\"
81 documentation for details). If these cases the limit is substantially larger.
82 However, the speed of execution will be slower.
84 All values in repeating quantifiers must be less than 65536.
85 The maximum number of capturing subpatterns is 65535.
87 There is no limit to the number of non-capturing subpatterns, but the maximum
88 depth of nesting of all kinds of parenthesized subpattern, including capturing
89 subpatterns, assertions, and other types of subpattern, is 200.
91 The maximum length of a subject string is the largest positive number that an
92 integer variable can hold. However, PCRE uses recursion to handle subpatterns
93 and indefinite repetition. This means that the available stack space may limit
94 the size of a subject string that can be processed by certain patterns.
96 .\" HTML <a name="utf8support"></a>
98 .rs
99 .sp
100 Starting at release 3.3, PCRE has had some support for character strings
101 encoded in the UTF-8 format. For release 4.0 this has been greatly extended to
102 cover most common requirements.
104 In order process UTF-8 strings, you must build PCRE to include UTF-8 support in
105 the code, and, in addition, you must call
106 .\" HREF
107 \fBpcre_compile()\fR
108 .\"
109 with the PCRE_UTF8 option flag. When you do this, both the pattern and any
110 subject strings that are matched against it are treated as UTF-8 strings
111 instead of just strings of bytes.
113 If you compile PCRE with UTF-8 support, but do not use it at run time, the
114 library will be a bit bigger, but the additional run time overhead is limited
115 to testing the PCRE_UTF8 flag in several places, so should not be very large.
117 The following comments apply when PCRE is running in UTF-8 mode:
119 1. When you set the PCRE_UTF8 flag, the strings passed as patterns and subjects
120 are checked for validity on entry to the relevant functions. If an invalid
121 UTF-8 string is passed, an error return is given. In some situations, you may
122 already know that your strings are valid, and therefore want to skip these
123 checks in order to improve performance. If you set the PCRE_NO_UTF8_CHECK flag
124 at compile time or at run time, PCRE assumes that the pattern or subject it
125 is given (respectively) contains only valid UTF-8 codes. In this case, it does
126 not diagnose an invalid UTF-8 string. If you pass an invalid UTF-8 string to
127 PCRE when PCRE_NO_UTF8_CHECK is set, the results are undefined. Your program
128 may crash.
130 2. In a pattern, the escape sequence \\x{...}, where the contents of the braces
131 is a string of hexadecimal digits, is interpreted as a UTF-8 character whose
132 code number is the given hexadecimal number, for example: \\x{1234}. If a
133 non-hexadecimal digit appears between the braces, the item is not recognized.
134 This escape sequence can be used either as a literal, or within a character
135 class.
137 3. The original hexadecimal escape sequence, \\xhh, matches a two-byte UTF-8
138 character if the value is greater than 127.
140 4. Repeat quantifiers apply to complete UTF-8 characters, not to individual
141 bytes, for example: \\x{100}{3}.
143 5. The dot metacharacter matches one UTF-8 character instead of a single byte.
145 6. The escape sequence \\C can be used to match a single byte in UTF-8 mode,
146 but its use can lead to some strange effects.
148 7. The character escapes \\b, \\B, \\d, \\D, \\s, \\S, \\w, and \\W correctly
149 test characters of any code value, but the characters that PCRE recognizes as
150 digits, spaces, or word characters remain the same set as before, all with
151 values less than 256.
153 8. Case-insensitive matching applies only to characters whose values are less
154 than 256. PCRE does not support the notion of "case" for higher-valued
155 characters.
157 9. PCRE does not support the use of Unicode tables and properties or the Perl
158 escapes \\p, \\P, and \\X.
161 .rs
162 .sp
163 Philip Hazel <ph10@cam.ac.uk>
164 .br
165 University Computing Service,
166 .br
167 Cambridge CB2 3QG, England.
168 .br
169 Phone: +44 1223 334714
171 .in 0
172 Last updated: 20 August 2003
173 .br
174 Copyright (c) 1997-2003 University of Cambridge.

  ViewVC Help
Powered by ViewVC 1.1.5