ViewVC logotype

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

Parent Directory Parent Directory | Revision Log Revision Log

Revision 63 - (show annotations)
Sat Feb 24 21:40:03 2007 UTC (14 years, 2 months ago) by nigel
File size: 6405 byte(s)
Error occurred while calculating annotation data.
Load pcre-4.0 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. PCRE assumes that the strings it is given contain valid UTF-8 codes. It does
120 not diagnose invalid UTF-8 strings. If you pass invalid UTF-8 strings to PCRE,
121 the results are undefined.
123 2. In a pattern, the escape sequence \\x{...}, where the contents of the braces
124 is a string of hexadecimal digits, is interpreted as a UTF-8 character whose
125 code number is the given hexadecimal number, for example: \\x{1234}. If a
126 non-hexadecimal digit appears between the braces, the item is not recognized.
127 This escape sequence can be used either as a literal, or within a character
128 class.
130 3. The original hexadecimal escape sequence, \\xhh, matches a two-byte UTF-8
131 character if the value is greater than 127.
133 4. Repeat quantifiers apply to complete UTF-8 characters, not to individual
134 bytes, for example: \\x{100}{3}.
136 5. The dot metacharacter matches one UTF-8 character instead of a single byte.
138 6. The escape sequence \\C can be used to match a single byte in UTF-8 mode,
139 but its use can lead to some strange effects.
141 7. The character escapes \\b, \\B, \\d, \\D, \\s, \\S, \\w, and \\W correctly
142 test characters of any code value, but the characters that PCRE recognizes as
143 digits, spaces, or word characters remain the same set as before, all with
144 values less than 256.
146 8. Case-insensitive matching applies only to characters whose values are less
147 than 256. PCRE does not support the notion of "case" for higher-valued
148 characters.
150 9. PCRE does not support the use of Unicode tables and properties or the Perl
151 escapes \\p, \\P, and \\X.
154 .rs
155 .sp
156 Philip Hazel <ph10@cam.ac.uk>
157 .br
158 University Computing Service,
159 .br
160 Cambridge CB2 3QG, England.
161 .br
162 Phone: +44 1223 334714
164 .in 0
165 Last updated: 04 February 2003
166 .br
167 Copyright (c) 1997-2003 University of Cambridge.

  ViewVC Help
Powered by ViewVC 1.1.5