Home | History | Annotate | Download | only in html
      1 <html>
      2 <head>
      3 <title>pcre2 specification</title>
      4 </head>
      5 <body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
      6 <h1>pcre2 man page</h1>
      7 <p>
      8 Return to the <a href="index.html">PCRE2 index page</a>.
      9 </p>
     10 <p>
     11 This page is part of the PCRE2 HTML documentation. It was generated
     12 automatically from the original man page. If there is any nonsense in it,
     13 please consult the man page, in case the conversion went wrong.
     14 <br>
     15 <ul>
     16 <li><a name="TOC1" href="#SEC1">INTRODUCTION</a>
     17 <li><a name="TOC2" href="#SEC2">SECURITY CONSIDERATIONS</a>
     18 <li><a name="TOC3" href="#SEC3">USER DOCUMENTATION</a>
     19 <li><a name="TOC4" href="#SEC4">AUTHOR</a>
     20 <li><a name="TOC5" href="#SEC5">REVISION</a>
     21 </ul>
     22 <br><a name="SEC1" href="#TOC1">INTRODUCTION</a><br>
     23 <P>
     24 PCRE2 is the name used for a revised API for the PCRE library, which is a set
     25 of functions, written in C, that implement regular expression pattern matching
     26 using the same syntax and semantics as Perl, with just a few differences. Some
     27 features that appeared in Python and the original PCRE before they appeared in
     28 Perl are also available using the Python syntax. There is also some support for
     29 one or two .NET and Oniguruma syntax items, and there are options for
     30 requesting some minor changes that give better ECMAScript (aka JavaScript)
     31 compatibility.
     32 </P>
     33 <P>
     34 The source code for PCRE2 can be compiled to support 8-bit, 16-bit, or 32-bit
     35 code units, which means that up to three separate libraries may be installed.
     36 The original work to extend PCRE to 16-bit and 32-bit code units was done by
     37 Zoltan Herczeg and Christian Persch, respectively. In all three cases, strings
     38 can be interpreted either as one character per code unit, or as UTF-encoded
     39 Unicode, with support for Unicode general category properties. Unicode support
     40 is optional at build time (but is the default). However, processing strings as
     41 UTF code units must be enabled explicitly at run time. The version of Unicode
     42 in use can be discovered by running
     43 <pre>
     44   pcre2test -C
     45 </PRE>
     46 </P>
     47 <P>
     48 The three libraries contain identical sets of functions, with names ending in
     49 _8, _16, or _32, respectively (for example, <b>pcre2_compile_8()</b>). However,
     50 by defining PCRE2_CODE_UNIT_WIDTH to be 8, 16, or 32, a program that uses just
     51 one code unit width can be written using generic names such as
     52 <b>pcre2_compile()</b>, and the documentation is written assuming that this is
     53 the case.
     54 </P>
     55 <P>
     56 In addition to the Perl-compatible matching function, PCRE2 contains an
     57 alternative function that matches the same compiled patterns in a different
     58 way. In certain circumstances, the alternative function has some advantages.
     59 For a discussion of the two matching algorithms, see the
     60 <a href="pcre2matching.html"><b>pcre2matching</b></a>
     61 page.
     62 </P>
     63 <P>
     64 Details of exactly which Perl regular expression features are and are not
     65 supported by PCRE2 are given in separate documents. See the
     66 <a href="pcre2pattern.html"><b>pcre2pattern</b></a>
     67 and
     68 <a href="pcre2compat.html"><b>pcre2compat</b></a>
     69 pages. There is a syntax summary in the
     70 <a href="pcre2syntax.html"><b>pcre2syntax</b></a>
     71 page.
     72 </P>
     73 <P>
     74 Some features of PCRE2 can be included, excluded, or changed when the library
     75 is built. The
     76 <a href="pcre2_config.html"><b>pcre2_config()</b></a>
     77 function makes it possible for a client to discover which features are
     78 available. The features themselves are described in the
     79 <a href="pcre2build.html"><b>pcre2build</b></a>
     80 page. Documentation about building PCRE2 for various operating systems can be
     81 found in the
     82 <a href="README.txt"><b>README</b></a>
     83 and
     84 <a href="NON-AUTOTOOLS-BUILD.txt"><b>NON-AUTOTOOLS_BUILD</b></a>
     85 files in the source distribution.
     86 </P>
     87 <P>
     88 The libraries contains a number of undocumented internal functions and data
     89 tables that are used by more than one of the exported external functions, but
     90 which are not intended for use by external callers. Their names all begin with
     91 "_pcre2", which hopefully will not provoke any name clashes. In some
     92 environments, it is possible to control which external symbols are exported
     93 when a shared library is built, and in these cases the undocumented symbols are
     94 not exported.
     95 </P>
     96 <br><a name="SEC2" href="#TOC1">SECURITY CONSIDERATIONS</a><br>
     97 <P>
     98 If you are using PCRE2 in a non-UTF application that permits users to supply
     99 arbitrary patterns for compilation, you should be aware of a feature that
    100 allows users to turn on UTF support from within a pattern. For example, an
    101 8-bit pattern that begins with "(*UTF)" turns on UTF-8 mode, which interprets
    102 patterns and subjects as strings of UTF-8 code units instead of individual
    103 8-bit characters. This causes both the pattern and any data against which it is
    104 matched to be checked for UTF-8 validity. If the data string is very long, such
    105 a check might use sufficiently many resources as to cause your application to
    106 lose performance.
    107 </P>
    108 <P>
    109 One way of guarding against this possibility is to use the
    110 <b>pcre2_pattern_info()</b> function to check the compiled pattern's options for
    111 PCRE2_UTF. Alternatively, you can set the PCRE2_NEVER_UTF option when calling
    112 <b>pcre2_compile()</b>. This causes an compile time error if a pattern contains
    113 a UTF-setting sequence.
    114 </P>
    115 <P>
    116 The use of Unicode properties for character types such as \d can also be
    117 enabled from within the pattern, by specifying "(*UCP)". This feature can be
    118 disallowed by setting the PCRE2_NEVER_UCP option.
    119 </P>
    120 <P>
    121 If your application is one that supports UTF, be aware that validity checking
    122 can take time. If the same data string is to be matched many times, you can use
    123 the PCRE2_NO_UTF_CHECK option for the second and subsequent matches to avoid
    124 running redundant checks.
    125 </P>
    126 <P>
    127 The use of the \C escape sequence in a UTF-8 or UTF-16 pattern can lead to
    128 problems, because it may leave the current matching point in the middle of a
    129 multi-code-unit character. The PCRE2_NEVER_BACKSLASH_C option can be used by an
    130 application to lock out the use of \C, causing a compile-time error if it is
    131 encountered. It is also possible to build PCRE2 with the use of \C permanently
    132 disabled.
    133 </P>
    134 <P>
    135 Another way that performance can be hit is by running a pattern that has a very
    136 large search tree against a string that will never match. Nested unlimited
    137 repeats in a pattern are a common example. PCRE2 provides some protection
    138 against this: see the <b>pcre2_set_match_limit()</b> function in the
    139 <a href="pcre2api.html"><b>pcre2api</b></a>
    140 page.
    141 </P>
    142 <br><a name="SEC3" href="#TOC1">USER DOCUMENTATION</a><br>
    143 <P>
    144 The user documentation for PCRE2 comprises a number of different sections. In
    145 the "man" format, each of these is a separate "man page". In the HTML format,
    146 each is a separate page, linked from the index page. In the plain text format,
    147 the descriptions of the <b>pcre2grep</b> and <b>pcre2test</b> programs are in
    148 files called <b>pcre2grep.txt</b> and <b>pcre2test.txt</b>, respectively. The
    149 remaining sections, except for the <b>pcre2demo</b> section (which is a program
    150 listing), and the short pages for individual functions, are concatenated in
    151 <b>pcre2.txt</b>, for ease of searching. The sections are as follows:
    152 <pre>
    153   pcre2              this document
    154   pcre2-config       show PCRE2 installation configuration information
    155   pcre2api           details of PCRE2's native C API
    156   pcre2build         building PCRE2
    157   pcre2callout       details of the callout feature
    158   pcre2compat        discussion of Perl compatibility
    159   pcre2demo          a demonstration C program that uses PCRE2
    160   pcre2grep          description of the <b>pcre2grep</b> command (8-bit only)
    161   pcre2jit           discussion of just-in-time optimization support
    162   pcre2limits        details of size and other limits
    163   pcre2matching      discussion of the two matching algorithms
    164   pcre2partial       details of the partial matching facility
    165   pcre2pattern       syntax and semantics of supported regular expression patterns
    166   pcre2perform       discussion of performance issues
    167   pcre2posix         the POSIX-compatible C API for the 8-bit library
    168   pcre2sample        discussion of the pcre2demo program
    169   pcre2stack         discussion of stack usage
    170   pcre2syntax        quick syntax reference
    171   pcre2test          description of the <b>pcre2test</b> command
    172   pcre2unicode       discussion of Unicode and UTF support
    173 </pre>
    174 In the "man" and HTML formats, there is also a short page for each C library
    175 function, listing its arguments and results.
    176 </P>
    177 <br><a name="SEC4" href="#TOC1">AUTHOR</a><br>
    178 <P>
    179 Philip Hazel
    180 <br>
    181 University Computing Service
    182 <br>
    183 Cambridge, England.
    184 <br>
    185 </P>
    186 <P>
    187 Putting an actual email address here is a spam magnet. If you want to email me,
    188 use my two initials, followed by the two digits 10, at the domain cam.ac.uk.
    189 </P>
    190 <br><a name="SEC5" href="#TOC1">REVISION</a><br>
    191 <P>
    192 Last updated: 16 October 2015
    193 <br>
    194 Copyright &copy; 1997-2015 University of Cambridge.
    195 <br>
    196 <p>
    197 Return to the <a href="index.html">PCRE2 index page</a>.
    198 </p>
    199