• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<title>pcre specification</title>
4</head>
5<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
6<h1>pcre man page</h1>
7<p>
8Return to the <a href="index.html">PCRE index page</a>.
9</p>
10<p>
11This page is part of the PCRE HTML documentation. It was generated automatically
12from the original man page. If there is any nonsense in it, please consult the
13man page, in case the conversion went wrong.
14<br>
15<ul>
16<li><a name="TOC1" href="#SEC1">PLEASE TAKE NOTE</a>
17<li><a name="TOC2" href="#SEC2">INTRODUCTION</a>
18<li><a name="TOC3" href="#SEC3">SECURITY CONSIDERATIONS</a>
19<li><a name="TOC4" href="#SEC4">USER DOCUMENTATION</a>
20<li><a name="TOC5" href="#SEC5">AUTHOR</a>
21<li><a name="TOC6" href="#SEC6">REVISION</a>
22</ul>
23<br><a name="SEC1" href="#TOC1">PLEASE TAKE NOTE</a><br>
24<P>
25This document relates to PCRE releases that use the original API,
26with library names libpcre, libpcre16, and libpcre32. January 2015 saw the
27first release of a new API, known as PCRE2, with release numbers starting at
2810.00 and library names libpcre2-8, libpcre2-16, and libpcre2-32. The old
29libraries (now called PCRE1) are still being maintained for bug fixes, but
30there will be no new development. New projects are advised to use the new PCRE2
31libraries.
32</P>
33<br><a name="SEC2" href="#TOC1">INTRODUCTION</a><br>
34<P>
35The PCRE library is a set of functions that implement regular expression
36pattern matching using the same syntax and semantics as Perl, with just a few
37differences. Some features that appeared in Python and PCRE before they
38appeared in Perl are also available using the Python syntax, there is some
39support for one or two .NET and Oniguruma syntax items, and there is an option
40for requesting some minor changes that give better JavaScript compatibility.
41</P>
42<P>
43Starting with release 8.30, it is possible to compile two separate PCRE
44libraries: the original, which supports 8-bit character strings (including
45UTF-8 strings), and a second library that supports 16-bit character strings
46(including UTF-16 strings). The build process allows either one or both to be
47built. The majority of the work to make this possible was done by Zoltan
48Herczeg.
49</P>
50<P>
51Starting with release 8.32 it is possible to compile a third separate PCRE
52library that supports 32-bit character strings (including UTF-32 strings). The
53build process allows any combination of the 8-, 16- and 32-bit libraries. The
54work to make this possible was done by Christian Persch.
55</P>
56<P>
57The three libraries contain identical sets of functions, except that the names
58in the 16-bit library start with <b>pcre16_</b> instead of <b>pcre_</b>, and the
59names in the 32-bit library start with <b>pcre32_</b> instead of <b>pcre_</b>. To
60avoid over-complication and reduce the documentation maintenance load, most of
61the documentation describes the 8-bit library, with the differences for the
6216-bit and 32-bit libraries described separately in the
63<a href="pcre16.html"><b>pcre16</b></a>
64and
65<a href="pcre32.html"><b>pcre32</b></a>
66pages. References to functions or structures of the form <i>pcre[16|32]_xxx</i>
67should be read as meaning "<i>pcre_xxx</i> when using the 8-bit library,
68<i>pcre16_xxx</i> when using the 16-bit library, or <i>pcre32_xxx</i> when using
69the 32-bit library".
70</P>
71<P>
72The current implementation of PCRE corresponds approximately with Perl 5.12,
73including support for UTF-8/16/32 encoded strings and Unicode general category
74properties. However, UTF-8/16/32 and Unicode support has to be explicitly
75enabled; it is not the default. The Unicode tables correspond to Unicode
76release 6.3.0.
77</P>
78<P>
79In addition to the Perl-compatible matching function, PCRE contains an
80alternative function that matches the same compiled patterns in a different
81way. In certain circumstances, the alternative function has some advantages.
82For a discussion of the two matching algorithms, see the
83<a href="pcrematching.html"><b>pcrematching</b></a>
84page.
85</P>
86<P>
87PCRE is written in C and released as a C library. A number of people have
88written wrappers and interfaces of various kinds. In particular, Google Inc.
89have provided a comprehensive C++ wrapper for the 8-bit library. This is now
90included as part of the PCRE distribution. The
91<a href="pcrecpp.html"><b>pcrecpp</b></a>
92page has details of this interface. Other people's contributions can be found
93in the <i>Contrib</i> directory at the primary FTP site, which is:
94<a href="ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre">ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre</a>
95</P>
96<P>
97Details of exactly which Perl regular expression features are and are not
98supported by PCRE are given in separate documents. See the
99<a href="pcrepattern.html"><b>pcrepattern</b></a>
100and
101<a href="pcrecompat.html"><b>pcrecompat</b></a>
102pages. There is a syntax summary in the
103<a href="pcresyntax.html"><b>pcresyntax</b></a>
104page.
105</P>
106<P>
107Some features of PCRE can be included, excluded, or changed when the library is
108built. The
109<a href="pcre_config.html"><b>pcre_config()</b></a>
110function makes it possible for a client to discover which features are
111available. The features themselves are described in the
112<a href="pcrebuild.html"><b>pcrebuild</b></a>
113page. Documentation about building PCRE for various operating systems can be
114found in the
115<a href="README.txt"><b>README</b></a>
116and
117<a href="NON-AUTOTOOLS-BUILD.txt"><b>NON-AUTOTOOLS_BUILD</b></a>
118files in the source distribution.
119</P>
120<P>
121The libraries contains a number of undocumented internal functions and data
122tables that are used by more than one of the exported external functions, but
123which are not intended for use by external callers. Their names all begin with
124"_pcre_" or "_pcre16_" or "_pcre32_", which hopefully will not provoke any name
125clashes. In some environments, it is possible to control which external symbols
126are exported when a shared library is built, and in these cases the
127undocumented symbols are not exported.
128</P>
129<br><a name="SEC3" href="#TOC1">SECURITY CONSIDERATIONS</a><br>
130<P>
131If you are using PCRE in a non-UTF application that permits users to supply
132arbitrary patterns for compilation, you should be aware of a feature that
133allows users to turn on UTF support from within a pattern, provided that PCRE
134was built with UTF support. For example, an 8-bit pattern that begins with
135"(*UTF8)" or "(*UTF)" turns on UTF-8 mode, which interprets patterns and
136subjects as strings of UTF-8 characters instead of individual 8-bit characters.
137This causes both the pattern and any data against which it is matched to be
138checked for UTF-8 validity. If the data string is very long, such a check might
139use sufficiently many resources as to cause your application to lose
140performance.
141</P>
142<P>
143One way of guarding against this possibility is to use the
144<b>pcre_fullinfo()</b> function to check the compiled pattern's options for UTF.
145Alternatively, from release 8.33, you can set the PCRE_NEVER_UTF option at
146compile time. This causes an compile time error if a pattern contains a
147UTF-setting sequence.
148</P>
149<P>
150If your application is one that supports UTF, be aware that validity checking
151can take time. If the same data string is to be matched many times, you can use
152the PCRE_NO_UTF[8|16|32]_CHECK option for the second and subsequent matches to
153save redundant checks.
154</P>
155<P>
156Another way that performance can be hit is by running a pattern that has a very
157large search tree against a string that will never match. Nested unlimited
158repeats in a pattern are a common example. PCRE provides some protection
159against this: see the PCRE_EXTRA_MATCH_LIMIT feature in the
160<a href="pcreapi.html"><b>pcreapi</b></a>
161page.
162</P>
163<br><a name="SEC4" href="#TOC1">USER DOCUMENTATION</a><br>
164<P>
165The user documentation for PCRE comprises a number of different sections. In
166the "man" format, each of these is a separate "man page". In the HTML format,
167each is a separate page, linked from the index page. In the plain text format,
168the descriptions of the <b>pcregrep</b> and <b>pcretest</b> programs are in files
169called <b>pcregrep.txt</b> and <b>pcretest.txt</b>, respectively. The remaining
170sections, except for the <b>pcredemo</b> section (which is a program listing),
171are concatenated in <b>pcre.txt</b>, for ease of searching. The sections are as
172follows:
173<pre>
174  pcre              this document
175  pcre-config       show PCRE installation configuration information
176  pcre16            details of the 16-bit library
177  pcre32            details of the 32-bit library
178  pcreapi           details of PCRE's native C API
179  pcrebuild         building PCRE
180  pcrecallout       details of the callout feature
181  pcrecompat        discussion of Perl compatibility
182  pcrecpp           details of the C++ wrapper for the 8-bit library
183  pcredemo          a demonstration C program that uses PCRE
184  pcregrep          description of the <b>pcregrep</b> command (8-bit only)
185  pcrejit           discussion of the just-in-time optimization support
186  pcrelimits        details of size and other limits
187  pcrematching      discussion of the two matching algorithms
188  pcrepartial       details of the partial matching facility
189  pcrepattern       syntax and semantics of supported regular expressions
190  pcreperform       discussion of performance issues
191  pcreposix         the POSIX-compatible C API for the 8-bit library
192  pcreprecompile    details of saving and re-using precompiled patterns
193  pcresample        discussion of the pcredemo program
194  pcrestack         discussion of stack usage
195  pcresyntax        quick syntax reference
196  pcretest          description of the <b>pcretest</b> testing command
197  pcreunicode       discussion of Unicode and UTF-8/16/32 support
198</pre>
199In the "man" and HTML formats, there is also a short page for each C library
200function, listing its arguments and results.
201</P>
202<br><a name="SEC5" href="#TOC1">AUTHOR</a><br>
203<P>
204Philip Hazel
205<br>
206University Computing Service
207<br>
208Cambridge CB2 3QH, England.
209<br>
210</P>
211<P>
212Putting an actual email address here seems to have been a spam magnet, so I've
213taken it away. If you want to email me, use my two initials, followed by the
214two digits 10, at the domain cam.ac.uk.
215</P>
216<br><a name="SEC6" href="#TOC1">REVISION</a><br>
217<P>
218Last updated: 10 February 2015
219<br>
220Copyright &copy; 1997-2015 University of Cambridge.
221<br>
222<p>
223Return to the <a href="index.html">PCRE index page</a>.
224</p>
225