/[pcre]/code/trunk/doc/pcre.3
ViewVC logotype

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 63 - (hide annotations) (download)
Sat Feb 24 21:40:03 2007 UTC (7 years, 6 months ago) by nigel
File size: 6405 byte(s)
Load pcre-4.0 into code/trunk.

1 nigel 41 .TH PCRE 3
2     .SH NAME
3 nigel 63 PCRE - Perl-compatible regular expressions
4 nigel 41 .SH DESCRIPTION
5 nigel 63 .rs
6     .sp
7 nigel 41 The PCRE library is a set of functions that implement regular expression
8 nigel 63 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.
12 nigel 41
13 nigel 63 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:
17 nigel 41
18 nigel 63 .\" 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
21 nigel 41
22 nigel 63 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.
32 nigel 49
33 nigel 63 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.
41 nigel 41
42 nigel 63 .SH USER DOCUMENTATION
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:
50 nigel 49
51 nigel 63 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
63 nigel 41
64 nigel 63 In addition, in the "man" and HTML formats, there is a short page for each
65     library function, listing its arguments and results.
66 nigel 41
67     .SH LIMITATIONS
68 nigel 63 .rs
69     .sp
70 nigel 41 There are some size limitations in PCRE but it is hoped that they will never in
71     practice be relevant.
72 nigel 63
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.
83    
84 nigel 41 All values in repeating quantifiers must be less than 65536.
85 nigel 63 The maximum number of capturing subpatterns is 65535.
86    
87 nigel 53 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 nigel 41 subpatterns, assertions, and other types of subpattern, is 200.
90    
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.
95    
96 nigel 63 .\" HTML <a name="utf8support"></a>
97 nigel 49 .SH UTF-8 SUPPORT
98 nigel 63 .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.
103 nigel 49
104 nigel 63 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.
112    
113 nigel 49 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.
116    
117 nigel 63 The following comments apply when PCRE is running in UTF-8 mode:
118    
119     1. PCRE assumes that the strings it is given contain valid UTF-8 codes. It does
120 nigel 49 not diagnose invalid UTF-8 strings. If you pass invalid UTF-8 strings to PCRE,
121     the results are undefined.
122    
123 nigel 63 2. In a pattern, the escape sequence \\x{...}, where the contents of the braces
124 nigel 49 is a string of hexadecimal digits, is interpreted as a UTF-8 character whose
125 nigel 63 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.
129 nigel 49
130 nigel 63 3. The original hexadecimal escape sequence, \\xhh, matches a two-byte UTF-8
131     character if the value is greater than 127.
132 nigel 49
133 nigel 63 4. Repeat quantifiers apply to complete UTF-8 characters, not to individual
134     bytes, for example: \\x{100}{3}.
135 nigel 49
136 nigel 63 5. The dot metacharacter matches one UTF-8 character instead of a single byte.
137 nigel 49
138 nigel 63 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.
140 nigel 49
141 nigel 63 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.
145 nigel 49
146 nigel 63 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.
149 nigel 49
150 nigel 63 9. PCRE does not support the use of Unicode tables and properties or the Perl
151     escapes \\p, \\P, and \\X.
152 nigel 49
153 nigel 41 .SH AUTHOR
154 nigel 63 .rs
155     .sp
156 nigel 41 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
163    
164 nigel 63 .in 0
165     Last updated: 04 February 2003
166 nigel 41 .br
167 nigel 63 Copyright (c) 1997-2003 University of Cambridge.

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12