summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2012-01-14 11:16:23 +0000
committerph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2012-01-14 11:16:23 +0000
commit57607b5518c705150a68606724fb875c7ba2686f (patch)
tree50d07ccc0c6d9e7698ea7ddef24bc333d7f58d11
parent36aa4021b0390d7727d5e1b11aac2fc87765792a (diff)
downloadpcre-57607b5518c705150a68606724fb875c7ba2686f.tar.gz
Bring HTML docs up to date.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@869 2f5784b3-3f2a-0410-8824-cb99058d5e15
-rw-r--r--doc/html/index.html25
-rw-r--r--doc/html/pcre-config.html29
-rw-r--r--doc/html/pcre.html54
-rw-r--r--doc/html/pcre16.html377
-rw-r--r--doc/html/pcre_assign_jit_stack.html14
-rw-r--r--doc/html/pcre_compile.html19
-rw-r--r--doc/html/pcre_compile2.html20
-rw-r--r--doc/html/pcre_config.html12
-rw-r--r--doc/html/pcre_copy_named_substring.html10
-rw-r--r--doc/html/pcre_copy_substring.html9
-rw-r--r--doc/html/pcre_dfa_exec.html18
-rw-r--r--doc/html/pcre_exec.html12
-rw-r--r--doc/html/pcre_free_study.html5
-rw-r--r--doc/html/pcre_free_substring.html7
-rw-r--r--doc/html/pcre_free_substring_list.html7
-rw-r--r--doc/html/pcre_fullinfo.html16
-rw-r--r--doc/html/pcre_get_named_substring.html19
-rw-r--r--doc/html/pcre_get_stringnumber.html8
-rw-r--r--doc/html/pcre_get_stringtable_entries.html6
-rw-r--r--doc/html/pcre_get_substring.html18
-rw-r--r--doc/html/pcre_get_substring_list.html20
-rw-r--r--doc/html/pcre_info.html39
-rw-r--r--doc/html/pcre_jit_stack_alloc.html9
-rw-r--r--doc/html/pcre_jit_stack_free.html7
-rw-r--r--doc/html/pcre_maketables.html11
-rw-r--r--doc/html/pcre_pattern_to_host_byte_order.html54
-rw-r--r--doc/html/pcre_refcount.html3
-rw-r--r--doc/html/pcre_study.html9
-rw-r--r--doc/html/pcre_utf16_to_host_byte_order.html57
-rw-r--r--doc/html/pcre_version.html10
-rw-r--r--doc/html/pcreapi.html461
-rw-r--r--doc/html/pcrebuild.html151
-rw-r--r--doc/html/pcrecallout.html127
-rw-r--r--doc/html/pcrecompat.html12
-rw-r--r--doc/html/pcrecpp.html7
-rw-r--r--doc/html/pcrejit.html75
-rw-r--r--doc/html/pcrelimits.html15
-rw-r--r--doc/html/pcrematching.html39
-rw-r--r--doc/html/pcrepartial.html244
-rw-r--r--doc/html/pcrepattern.html286
-rw-r--r--doc/html/pcreperform.html37
-rw-r--r--doc/html/pcreposix.html11
-rw-r--r--doc/html/pcreprecompile.html79
-rw-r--r--doc/html/pcresample.html19
-rw-r--r--doc/html/pcrestack.html69
-rw-r--r--doc/html/pcresyntax.html25
-rw-r--r--doc/html/pcretest.html452
-rw-r--r--doc/html/pcreunicode.html150
-rw-r--r--doc/pcre-config.txt38
-rw-r--r--doc/pcre.txt3969
-rw-r--r--doc/pcresyntax.31
-rw-r--r--doc/pcretest.txt672
52 files changed, 4644 insertions, 3199 deletions
diff --git a/doc/html/index.html b/doc/html/index.html
index 75361fd..20720df 100644
--- a/doc/html/index.html
+++ b/doc/html/index.html
@@ -1,10 +1,10 @@
<html>
-<!-- This is a manually maintained file that is the root of the HTML version of
- the PCRE documentation. When the HTML documents are built from the man
- page versions, the entire doc/html directory is emptied, this file is then
- copied into doc/html/index.html, and the remaining files therein are
+<!-- This is a manually maintained file that is the root of the HTML version of
+ the PCRE documentation. When the HTML documents are built from the man
+ page versions, the entire doc/html directory is emptied, this file is then
+ copied into doc/html/index.html, and the remaining files therein are
created by the 132html script.
--->
+-->
<head>
<title>PCRE specification</title>
</head>
@@ -18,6 +18,9 @@ The HTML documentation for PCRE comprises the following pages:
<tr><td><a href="pcre.html">pcre</a></td>
<td>&nbsp;&nbsp;Introductory page</td></tr>
+<tr><td><a href="pcre16.html">pcre16</a></td>
+ <td>&nbsp;&nbsp;Discussion of the 16-bit PCRE library</td></tr>
+
<tr><td><a href="pcre-config.html">pcre-config</a></td>
<td>&nbsp;&nbsp;Information about the installation configuration</td></tr>
@@ -83,11 +86,11 @@ The HTML documentation for PCRE comprises the following pages:
</table>
<p>
-There are also individual pages that summarize the interface for each function
-in the library:
+There are also individual pages that summarize the interface for each function
+in the library. There is a single page for each pair of 8-bit/16-bit functions.
</p>
-<table>
+<table>
<tr><td><a href="pcre_assign_jit_stack.html">pcre_assign_jit_stack</a></td>
<td>&nbsp;&nbsp;Assign stack for JIT matching</td></tr>
@@ -150,6 +153,9 @@ in the library:
<tr><td><a href="pcre_maketables.html">pcre_maketables</a></td>
<td>&nbsp;&nbsp;Build character tables in current locale</td></tr>
+
+<tr><td><a href="pcre_pattern_to_host_byte_order.html">pcre_pattern_to_host_byte_order</a></td>
+ <td>&nbsp;&nbsp;Convert compiled pattern to host byte order if necessary</td></tr>
<tr><td><a href="pcre_refcount.html">pcre_refcount</a></td>
<td>&nbsp;&nbsp;Maintain reference count in compiled pattern</td></tr>
@@ -157,6 +163,9 @@ in the library:
<tr><td><a href="pcre_study.html">pcre_study</a></td>
<td>&nbsp;&nbsp;Study a compiled pattern</td></tr>
+<tr><td><a href="pcre_utf16_to_host_byte_order.html">pcre_utf16_to_host_byte_order</a></td>
+ <td>&nbsp;&nbsp;Convert UTF-16 string to host byte order if necessary</td></tr>
+
<tr><td><a href="pcre_version.html">pcre_version</a></td>
<td>&nbsp;&nbsp;Return PCRE version and release date</td></tr>
</table>
diff --git a/doc/html/pcre-config.html b/doc/html/pcre-config.html
index 0987745..141b805 100644
--- a/doc/html/pcre-config.html
+++ b/doc/html/pcre-config.html
@@ -23,12 +23,16 @@ man page, in case the conversion went wrong.
<br><a name="SEC1" href="#TOC1">SYNOPSIS</a><br>
<P>
<b>pcre-config [--prefix] [--exec-prefix] [--version] [--libs]</b>
-<b>[--libs-posix] [--cflags] [--cflags-posix]</b>
+<b>[--libs16] [--libs-cpp] [--libs-posix] [--cflags] </b>
+<b>[--cflags-posix]</b>
</P>
<br><a name="SEC2" href="#TOC1">DESCRIPTION</a><br>
<P>
<b>pcre-config</b> returns the configuration of the installed PCRE
-libraries and the options required to compile a program to use them.
+libraries and the options required to compile a program to use them. Some of
+the options apply only to the 8-bit or 16-bit libraries, respectively, and are
+not available if only one of those libraries has been built. If an unavailable
+option is encountered, the "usage" information is output.
</P>
<br><a name="SEC3" href="#TOC1">OPTIONS</a><br>
<P>
@@ -50,12 +54,23 @@ output.
<P>
<b>--libs</b>
Writes to the standard output the command line options required to link
-with PCRE (<b>-lpcre</b> on many systems).
+with the 8-bit PCRE library (<b>-lpcre</b> on many systems).
+</P>
+<P>
+<b>--libs16</b>
+Writes to the standard output the command line options required to link
+with the 16-bit PCRE library (<b>-lpcre16</b> on many systems).
+</P>
+<P>
+<b>--libs-cpp</b>
+Writes to the standard output the command line options required to link with
+PCRE's C++ wrapper library (<b>-lpcrecpp</b> <b>-lpcre</b> on many
+systems).
</P>
<P>
<b>--libs-posix</b>
Writes to the standard output the command line options required to link with
-the PCRE posix emulation library (<b>-lpcreposix</b> <b>-lpcre</b> on many
+PCRE's POSIX API wrapper library (<b>-lpcreposix</b> <b>-lpcre</b> on many
systems).
</P>
<P>
@@ -67,7 +82,7 @@ many systems).
<P>
<b>--cflags-posix</b>
Writes to the standard output the command line options required to compile
-files that use the PCRE posix emulation library (this may include some <b>-I</b>
+files that use PCRE's POSIX API wrapper library (this may include some <b>-I</b>
options, but is blank on many systems).
</P>
<br><a name="SEC4" href="#TOC1">SEE ALSO</a><br>
@@ -77,11 +92,11 @@ options, but is blank on many systems).
<br><a name="SEC5" href="#TOC1">AUTHOR</a><br>
<P>
This manual page was originally written by Mark Baker for the Debian GNU/Linux
-system. It has been slightly revised as a generic PCRE man page.
+system. It has been subsequently revised as a generic PCRE man page.
</P>
<br><a name="SEC6" href="#TOC1">REVISION</a><br>
<P>
-Last updated: 18 April 2007
+Last updated: 01 January 2012
<br>
<p>
Return to the <a href="index.html">PCRE index page</a>.
diff --git a/doc/html/pcre.html b/doc/html/pcre.html
index 9078f2d..52afb47 100644
--- a/doc/html/pcre.html
+++ b/doc/html/pcre.html
@@ -28,10 +28,29 @@ support for one or two .NET and Oniguruma syntax items, and there is an option
for requesting some minor changes that give better JavaScript compatibility.
</P>
<P>
+Starting with release 8.30, it is possible to compile two separate PCRE
+libraries: the original, which supports 8-bit character strings (including
+UTF-8 strings), and a second library that supports 16-bit character strings
+(including UTF-16 strings). The build process allows either one or both to be
+built. The majority of the work to make this possible was done by Zoltan
+Herczeg.
+</P>
+<P>
+The two libraries contain identical sets of functions, except that the names in
+the 16-bit library start with <b>pcre16_</b> instead of <b>pcre_</b>. To avoid
+over-complication and reduce the documentation maintenance load, most of the
+documentation describes the 8-bit library, with the differences for the 16-bit
+library described separately in the
+<a href="pcre16.html"><b>pcre16</b></a>
+page. References to functions or structures of the form <i>pcre[16]_xxx</i>
+should be read as meaning "<i>pcre_xxx</i> when using the 8-bit library and
+<i>pcre16_xxx</i> when using the 16-bit library".
+</P>
+<P>
The current implementation of PCRE corresponds approximately with Perl 5.12,
-including support for UTF-8 encoded strings and Unicode general category
-properties. However, UTF-8 and Unicode support has to be explicitly enabled; it
-is not the default. The Unicode tables correspond to Unicode release 6.0.0.
+including support for UTF-8/16 encoded strings and Unicode general category
+properties. However, UTF-8/16 and Unicode support has to be explicitly enabled;
+it is not the default. The Unicode tables correspond to Unicode release 6.0.0.
</P>
<P>
In addition to the Perl-compatible matching function, PCRE contains an
@@ -44,8 +63,8 @@ page.
<P>
PCRE is written in C and released as a C library. A number of people have
written wrappers and interfaces of various kinds. In particular, Google Inc.
-have provided a comprehensive C++ wrapper. This is now included as part of the
-PCRE distribution. The
+have provided a comprehensive C++ wrapper for the 8-bit library. This is now
+included as part of the PCRE distribution. The
<a href="pcrecpp.html"><b>pcrecpp</b></a>
page has details of this interface. Other people's contributions can be found
in the <i>Contrib</i> directory at the primary FTP site, which is:
@@ -73,13 +92,13 @@ found in the <b>README</b> and <b>NON-UNIX-USE</b> files in the source
distribution.
</P>
<P>
-The library contains a number of undocumented internal functions and data
+The libraries contains a number of undocumented internal functions and data
tables that are used by more than one of the exported external functions, but
which are not intended for use by external callers. Their names all begin with
-"_pcre_", which hopefully will not provoke any name clashes. In some
-environments, it is possible to control which external symbols are exported
-when a shared library is built, and in these cases the undocumented symbols are
-not exported.
+"_pcre_" or "_pcre16_", which hopefully will not provoke any name clashes. In
+some environments, it is possible to control which external symbols are
+exported when a shared library is built, and in these cases the undocumented
+symbols are not exported.
</P>
<br><a name="SEC2" href="#TOC1">USER DOCUMENTATION</a><br>
<P>
@@ -90,30 +109,31 @@ all the sections, except the <b>pcredemo</b> section, are concatenated, for ease
of searching. The sections are as follows:
<pre>
pcre this document
+ pcre16 details of the 16-bit library
pcre-config show PCRE installation configuration information
pcreapi details of PCRE's native C API
pcrebuild options for building PCRE
pcrecallout details of the callout feature
pcrecompat discussion of Perl compatibility
- pcrecpp details of the C++ wrapper
+ pcrecpp details of the C++ wrapper for the 8-bit library
pcredemo a demonstration C program that uses PCRE
- pcregrep description of the <b>pcregrep</b> command
+ pcregrep description of the <b>pcregrep</b> command (8-bit only)
pcrejit discussion of the just-in-time optimization support
pcrelimits details of size and other limits
pcrematching discussion of the two matching algorithms
pcrepartial details of the partial matching facility
pcrepattern syntax and semantics of supported regular expressions
pcreperform discussion of performance issues
- pcreposix the POSIX-compatible C API
+ pcreposix the POSIX-compatible C API for the 8-bit library
pcreprecompile details of saving and re-using precompiled patterns
pcresample discussion of the pcredemo program
pcrestack discussion of stack usage
pcresyntax quick syntax reference
pcretest description of the <b>pcretest</b> testing command
- pcreunicode discussion of Unicode and UTF-8 support
+ pcreunicode discussion of Unicode and UTF-8/16 support
</pre>
In addition, in the "man" and HTML formats, there is a short page for each
-C library function, listing its arguments and results.
+8-bit C library function, listing its arguments and results.
</P>
<br><a name="SEC3" href="#TOC1">AUTHOR</a><br>
<P>
@@ -131,9 +151,9 @@ two digits 10, at the domain cam.ac.uk.
</P>
<br><a name="SEC4" href="#TOC1">REVISION</a><br>
<P>
-Last updated: 24 August 2011
+Last updated: 10 January 2012
<br>
-Copyright &copy; 1997-2011 University of Cambridge.
+Copyright &copy; 1997-2012 University of Cambridge.
<br>
<p>
Return to the <a href="index.html">PCRE index page</a>.
diff --git a/doc/html/pcre16.html b/doc/html/pcre16.html
index e69de29..66e89cd 100644
--- a/doc/html/pcre16.html
+++ b/doc/html/pcre16.html
@@ -0,0 +1,377 @@
+<html>
+<head>
+<title>pcre16 specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>pcre16 man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+<ul>
+<li><a name="TOC1" href="#SEC1">PCRE 16-BIT API BASIC FUNCTIONS</a>
+<li><a name="TOC2" href="#SEC2">PCRE 16-BIT API STRING EXTRACTION FUNCTIONS</a>
+<li><a name="TOC3" href="#SEC3">PCRE 16-BIT API AUXILIARY FUNCTIONS</a>
+<li><a name="TOC4" href="#SEC4">PCRE 16-BIT API INDIRECTED FUNCTIONS</a>
+<li><a name="TOC5" href="#SEC5">PCRE 16-BIT API 16-BIT-ONLY FUNCTION</a>
+<li><a name="TOC6" href="#SEC6">THE PCRE 16-BIT LIBRARY</a>
+<li><a name="TOC7" href="#SEC7">THE HEADER FILE</a>
+<li><a name="TOC8" href="#SEC8">THE LIBRARY NAME</a>
+<li><a name="TOC9" href="#SEC9">STRING TYPES</a>
+<li><a name="TOC10" href="#SEC10">STRUCTURE TYPES</a>
+<li><a name="TOC11" href="#SEC11">16-BIT FUNCTIONS</a>
+<li><a name="TOC12" href="#SEC12">SUBJECT STRING OFFSETS</a>
+<li><a name="TOC13" href="#SEC13">NAMED SUBPATTERNS</a>
+<li><a name="TOC14" href="#SEC14">OPTION NAMES</a>
+<li><a name="TOC15" href="#SEC15">CHARACTER CODES</a>
+<li><a name="TOC16" href="#SEC16">ERROR NAMES</a>
+<li><a name="TOC17" href="#SEC17">ERROR TEXTS</a>
+<li><a name="TOC18" href="#SEC18">CALLOUTS</a>
+<li><a name="TOC19" href="#SEC19">TESTING</a>
+<li><a name="TOC20" href="#SEC20">NOT SUPPORTED IN 16-BIT MODE</a>
+<li><a name="TOC21" href="#SEC21">AUTHOR</a>
+<li><a name="TOC22" href="#SEC22">REVISION</a>
+</ul>
+<P>
+<b>#include &#60;pcre.h&#62;</b>
+</P>
+<br><a name="SEC1" href="#TOC1">PCRE 16-BIT API BASIC FUNCTIONS</a><br>
+<P>
+<b>pcre16 *pcre16_compile(PCRE_SPTR16 <i>pattern</i>, int <i>options</i>,</b>
+<b>const char **<i>errptr</i>, int *<i>erroffset</i>,</b>
+<b>const unsigned char *<i>tableptr</i>);</b>
+</P>
+<P>
+<b>pcre16 *pcre16_compile2(PCRE_SPTR16 <i>pattern</i>, int <i>options</i>,</b>
+<b>int *<i>errorcodeptr</i>,</b>
+<b>const char **<i>errptr</i>, int *<i>erroffset</i>,</b>
+<b>const unsigned char *<i>tableptr</i>);</b>
+</P>
+<P>
+<b>pcre16_extra *pcre16_study(const pcre16 *<i>code</i>, int <i>options</i>,</b>
+<b>const char **<i>errptr</i>);</b>
+</P>
+<P>
+<b>void pcre16_free_study(pcre16_extra *<i>extra</i>);</b>
+</P>
+<P>
+<b>int pcre16_exec(const pcre16 *<i>code</i>, const pcre16_extra *<i>extra</i>,</b>
+<b>PCRE_SPTR16 <i>subject</i>, int <i>length</i>, int <i>startoffset</i>,</b>
+<b>int <i>options</i>, int *<i>ovector</i>, int <i>ovecsize</i>);</b>
+</P>
+<P>
+<b>int pcre16_dfa_exec(const pcre16 *<i>code</i>, const pcre16_extra *<i>extra</i>,</b>
+<b>PCRE_SPTR16 <i>subject</i>, int <i>length</i>, int <i>startoffset</i>,</b>
+<b>int <i>options</i>, int *<i>ovector</i>, int <i>ovecsize</i>,</b>
+<b>int *<i>workspace</i>, int <i>wscount</i>);</b>
+</P>
+<br><a name="SEC2" href="#TOC1">PCRE 16-BIT API STRING EXTRACTION FUNCTIONS</a><br>
+<P>
+<b>int pcre16_copy_named_substring(const pcre16 *<i>code</i>,</b>
+<b>PCRE_SPTR16 <i>subject</i>, int *<i>ovector</i>,</b>
+<b>int <i>stringcount</i>, PCRE_SPTR16 <i>stringname</i>,</b>
+<b>PCRE_UCHAR16 *<i>buffer</i>, int <i>buffersize</i>);</b>
+</P>
+<P>
+<b>int pcre16_copy_substring(PCRE_SPTR16 <i>subject</i>, int *<i>ovector</i>,</b>
+<b>int <i>stringcount</i>, int <i>stringnumber</i>, PCRE_UCHAR16 *<i>buffer</i>,</b>
+<b>int <i>buffersize</i>);</b>
+</P>
+<P>
+<b>int pcre16_get_named_substring(const pcre16 *<i>code</i>,</b>
+<b>PCRE_SPTR16 <i>subject</i>, int *<i>ovector</i>,</b>
+<b>int <i>stringcount</i>, PCRE_SPTR16 <i>stringname</i>,</b>
+<b>PCRE_SPTR16 *<i>stringptr</i>);</b>
+</P>
+<P>
+<b>int pcre16_get_stringnumber(const pcre16 *<i>code</i>,</b>
+<b>PCRE_SPTR16 <i>name</i>);</b>
+</P>
+<P>
+<b>int pcre16_get_stringtable_entries(const pcre16 *<i>code</i>,</b>
+<b>PCRE_SPTR16 <i>name</i>, PCRE_UCHAR16 **<i>first</i>, PCRE_UCHAR16 **<i>last</i>);</b>
+</P>
+<P>
+<b>int pcre16_get_substring(PCRE_SPTR16 <i>subject</i>, int *<i>ovector</i>,</b>
+<b>int <i>stringcount</i>, int <i>stringnumber</i>,</b>
+<b>PCRE_SPTR16 *<i>stringptr</i>);</b>
+</P>
+<P>
+<b>int pcre16_get_substring_list(PCRE_SPTR16 <i>subject</i>,</b>
+<b>int *<i>ovector</i>, int <i>stringcount</i>, PCRE_SPTR16 **<i>listptr</i>);</b>
+</P>
+<P>
+<b>void pcre16_free_substring(PCRE_SPTR16 <i>stringptr</i>);</b>
+</P>
+<P>
+<b>void pcre16_free_substring_list(PCRE_SPTR16 *<i>stringptr</i>);</b>
+</P>
+<br><a name="SEC3" href="#TOC1">PCRE 16-BIT API AUXILIARY FUNCTIONS</a><br>
+<P>
+<b>pcre16_jit_stack *pcre16_jit_stack_alloc(int <i>startsize</i>, int <i>maxsize</i>);</b>
+</P>
+<P>
+<b>void pcre16_jit_stack_free(pcre16_jit_stack *<i>stack</i>);</b>
+</P>
+<P>
+<b>void pcre16_assign_jit_stack(pcre16_extra *<i>extra</i>,</b>
+<b>pcre16_jit_callback <i>callback</i>, void *<i>data</i>);</b>
+</P>
+<P>
+<b>const unsigned char *pcre16_maketables(void);</b>
+</P>
+<P>
+<b>int pcre16_fullinfo(const pcre16 *<i>code</i>, const pcre16_extra *<i>extra</i>,</b>
+<b>int <i>what</i>, void *<i>where</i>);</b>
+</P>
+<P>
+<b>int pcre16_refcount(pcre16 *<i>code</i>, int <i>adjust</i>);</b>
+</P>
+<P>
+<b>int pcre16_config(int <i>what</i>, void *<i>where</i>);</b>
+</P>
+<P>
+<b>const char *pcre16_version(void);</b>
+</P>
+<P>
+<b>int pcre16_pattern_to_host_byte_order(pcre16 *<i>code</i>,</b>
+<b>pcre16_extra *<i>extra</i>, const unsigned char *<i>tables</i>);</b>
+</P>
+<br><a name="SEC4" href="#TOC1">PCRE 16-BIT API INDIRECTED FUNCTIONS</a><br>
+<P>
+<b>void *(*pcre16_malloc)(size_t);</b>
+</P>
+<P>
+<b>void (*pcre16_free)(void *);</b>
+</P>
+<P>
+<b>void *(*pcre16_stack_malloc)(size_t);</b>
+</P>
+<P>
+<b>void (*pcre16_stack_free)(void *);</b>
+</P>
+<P>
+<b>int (*pcre16_callout)(pcre16_callout_block *);</b>
+</P>
+<br><a name="SEC5" href="#TOC1">PCRE 16-BIT API 16-BIT-ONLY FUNCTION</a><br>
+<P>
+<b>int pcre16_utf16_to_host_byte_order(PCRE_UCHAR16 *<i>output</i>,</b>
+<b>PCRE_SPTR16 <i>input</i>, int <i>length</i>, int *<i>byte_order</i>, </b>
+<b>int <i>keep_boms</i>);</b>
+</P>
+<br><a name="SEC6" href="#TOC1">THE PCRE 16-BIT LIBRARY</a><br>
+<P>
+Starting with release 8.30, it is possible to compile a PCRE library that
+supports 16-bit character strings, including UTF-16 strings, as well as or
+instead of the original 8-bit library. The majority of the work to make this
+possible was done by Zoltan Herczeg. The two libraries contain identical sets
+of functions, used in exactly the same way. Only the names of the functions and
+the data types of their arguments and results are different. To avoid
+over-complication and reduce the documentation maintenance load, most of the
+PCRE documentation describes the 8-bit library, with only occasional references
+to the 16-bit library. This page describes what is different when you use the
+16-bit library.
+</P>
+<P>
+WARNING: A single application can be linked with both libraries, but you must
+take care when processing any particular pattern to use functions from just one
+library. For example, if you want to study a pattern that was compiled with
+<b>pcre16_compile()</b>, you must do so with <b>pcre16_study()</b>, not
+<b>pcre_study()</b>, and you must free the study data with
+<b>pcre16_free_study()</b>.
+</P>
+<br><a name="SEC7" href="#TOC1">THE HEADER FILE</a><br>
+<P>
+There is only one header file, <b>pcre.h</b>. It contains prototypes for all the
+functions in both libraries, as well as definitions of flags, structures, error
+codes, etc.
+</P>
+<br><a name="SEC8" href="#TOC1">THE LIBRARY NAME</a><br>
+<P>
+In Unix-like systems, the 16-bit library is called <b>libpcre16</b>, and can
+normally be accesss by adding <b>-lpcre16</b> to the command for linking an
+application that uses PCRE.
+</P>
+<br><a name="SEC9" href="#TOC1">STRING TYPES</a><br>
+<P>
+In the 8-bit library, strings are passed to PCRE library functions as vectors
+of bytes with the C type "char *". In the 16-bit library, strings are passed as
+vectors of unsigned 16-bit quantities. The macro PCRE_UCHAR16 specifies an
+appropriate data type, and PCRE_SPTR16 is defined as "const PCRE_UCHAR16 *". In
+very many environments, "short int" is a 16-bit data type. When PCRE is built,
+it defines PCRE_UCHAR16 as "short int", but checks that it really is a 16-bit
+data type. If it is not, the build fails with an error message telling the
+maintainer to modify the definition appropriately.
+</P>
+<br><a name="SEC10" href="#TOC1">STRUCTURE TYPES</a><br>
+<P>
+The types of the opaque structures that are used for compiled 16-bit patterns
+and JIT stacks are <b>pcre16</b> and <b>pcre16_jit_stack</b> respectively. The
+type of the user-accessible structure that is returned by <b>pcre16_study()</b>
+is <b>pcre16_extra</b>, and the type of the structure that is used for passing
+data to a callout function is <b>pcre16_callout_block</b>. These structures
+contain the same fields, with the same names, as their 8-bit counterparts. The
+only difference is that pointers to character strings are 16-bit instead of
+8-bit types.
+</P>
+<br><a name="SEC11" href="#TOC1">16-BIT FUNCTIONS</a><br>
+<P>
+For every function in the 8-bit library there is a corresponding function in
+the 16-bit library with a name that starts with <b>pcre16_</b> instead of
+<b>pcre_</b>. The prototypes are listed above. In addition, there is one extra
+function, <b>pcre16_utf16_to_host_byte_order()</b>. This is a utility function
+that converts a UTF-16 character string to host byte order if necessary. The
+other 16-bit functions expect the strings they are passed to be in host byte
+order.
+</P>
+<P>
+The <i>input</i> and <i>output</i> arguments of
+<b>pcre16_utf16_to_host_byte_order()</b> may point to the same address, that is,
+conversion in place is supported. The output buffer must be at least as long as
+the input.
+</P>
+<P>
+The <i>length</i> argument specifies the number of 16-bit data units in the
+input string; a negative value specifies a zero-terminated string.
+</P>
+<P>
+If <i>byte_order</i> is NULL, it is assumed that the string starts off in host
+byte order. This may be changed by byte-order marks (BOMs) anywhere in the
+string (commonly as the first character).
+</P>
+<P>
+If <i>byte_order</i> is not NULL, a non-zero value of the integer to which it
+points means that the input starts off in host byte order, otherwise the
+opposite order is assumed. Again, BOMs in the string can change this. The final
+byte order is passed back at the end of processing.
+</P>
+<P>
+If <i>keep_boms</i> is not zero, byte-order mark characters (0xfeff) are copied
+into the output string. Otherwise they are discarded.
+</P>
+<P>
+The result of the function is the number of 16-bit units placed into the output
+buffer, including the zero terminator if the string was zero-terminated.
+</P>
+<br><a name="SEC12" href="#TOC1">SUBJECT STRING OFFSETS</a><br>
+<P>
+The offsets within subject strings that are returned by the matching functions
+are in 16-bit units rather than bytes.
+</P>
+<br><a name="SEC13" href="#TOC1">NAMED SUBPATTERNS</a><br>
+<P>
+The name-to-number translation table that is maintained for named subpatterns
+uses 16-bit characters. The <b>pcre16_get_stringtable_entries()</b> function
+returns the length of each entry in the table as the number of 16-bit data
+units.
+</P>
+<br><a name="SEC14" href="#TOC1">OPTION NAMES</a><br>
+<P>
+There are two new general option names, PCRE_UTF16 and PCRE_NO_UTF16_CHECK,
+which correspond to PCRE_UTF8 and PCRE_NO_UTF8_CHECK in the 8-bit library. In
+fact, these new options define the same bits in the options word.
+</P>
+<P>
+For the <b>pcre16_config()</b> function there is an option PCRE_CONFIG_UTF16
+that returns 1 if UTF-16 support is configured, otherwise 0. If this option is
+given to <b>pcre_config()</b>, or if the PCRE_CONFIG_UTF8 option is given to
+<b>pcre16_config()</b>, the result is the PCRE_ERROR_BADOPTION error.
+</P>
+<br><a name="SEC15" href="#TOC1">CHARACTER CODES</a><br>
+<P>
+In 16-bit mode, when PCRE_UTF16 is not set, character values are treated in the
+same way as in 8-bit, non UTF-8 mode, except, of course, that they can range
+from 0 to 0xffff instead of 0 to 0xff. Character types for characters less than
+0xff can therefore be influenced by the locale in the same way as before.
+Characters greater than 0xff have only one case, and no "type" (such as letter
+or digit).
+</P>
+<P>
+In UTF-16 mode, the character code is Unicode, in the range 0 to 0x10ffff, with
+the exception of values in the range 0xd800 to 0xdfff because those are
+"surrogate" values that are used in pairs to encode values greater than 0xffff.
+</P>
+<P>
+A UTF-16 string can indicate its endianness by special code knows as a
+byte-order mark (BOM). The PCRE functions do not handle this, expecting strings
+to be in host byte order. A utility function called
+<b>pcre16_utf16_to_host_byte_order()</b> is provided to help with this (see
+above).
+</P>
+<br><a name="SEC16" href="#TOC1">ERROR NAMES</a><br>
+<P>
+The errors PCRE_ERROR_BADUTF16_OFFSET and PCRE_ERROR_SHORTUTF16 correspond to
+their 8-bit counterparts. The error PCRE_ERROR_BADMODE is given when a compiled
+pattern is passed to a function that processes patterns in the other
+mode, for example, if a pattern compiled with <b>pcre_compile()</b> is passed to
+<b>pcre16_exec()</b>.
+</P>
+<P>
+There are new error codes whose names begin with PCRE_UTF16_ERR for invalid
+UTF-16 strings, corresponding to the PCRE_UTF8_ERR codes for UTF-8 strings that
+are described in the section entitled
+<a href="pcreapi.html#badutf8reasons">"Reason codes for invalid UTF-8 strings"</a>
+in the main
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page. The UTF-16 errors are:
+<pre>
+ PCRE_UTF16_ERR1 Missing low surrogate at end of string
+ PCRE_UTF16_ERR2 Invalid low surrogate follows high surrogate
+ PCRE_UTF16_ERR3 Isolated low surrogate
+ PCRE_UTF16_ERR4 Invalid character 0xfffe
+</PRE>
+</P>
+<br><a name="SEC17" href="#TOC1">ERROR TEXTS</a><br>
+<P>
+If there is an error while compiling a pattern, the error text that is passed
+back by <b>pcre16_compile()</b> or <b>pcre16_compile2()</b> is still an 8-bit
+character string, zero-terminated.
+</P>
+<br><a name="SEC18" href="#TOC1">CALLOUTS</a><br>
+<P>
+The <i>subject</i> and <i>mark</i> fields in the callout block that is passed to
+a callout function point to 16-bit vectors.
+</P>
+<br><a name="SEC19" href="#TOC1">TESTING</a><br>
+<P>
+The <b>pcretest</b> program continues to operate with 8-bit input and output
+files, but it can be used for testing the 16-bit library. If it is run with the
+command line option <b>-16</b>, patterns and subject strings are converted from
+8-bit to 16-bit before being passed to PCRE, and the 16-bit library functions
+are used instead of the 8-bit ones. Returned 16-bit strings are converted to
+8-bit for output. If the 8-bit library was not compiled, <b>pcretest</b>
+defaults to 16-bit and the <b>-16</b> option is ignored.
+</P>
+<P>
+When PCRE is being built, the <b>RunTest</b> script that is called by "make
+check" uses the <b>pcretest</b> <b>-C</b> option to discover which of the 8-bit
+and 16-bit libraries has been built, and runs the tests appropriately.
+</P>
+<br><a name="SEC20" href="#TOC1">NOT SUPPORTED IN 16-BIT MODE</a><br>
+<P>
+Not all the features of the 8-bit library are available with the 16-bit
+library. The C++ and POSIX wrapper functions support only the 8-bit library,
+and the <b>pcregrep</b> program is at present 8-bit only.
+</P>
+<br><a name="SEC21" href="#TOC1">AUTHOR</a><br>
+<P>
+Philip Hazel
+<br>
+University Computing Service
+<br>
+Cambridge CB2 3QH, England.
+<br>
+</P>
+<br><a name="SEC22" href="#TOC1">REVISION</a><br>
+<P>
+Last updated: 08 January 2012
+<br>
+Copyright &copy; 1997-2012 University of Cambridge.
+<br>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
diff --git a/doc/html/pcre_assign_jit_stack.html b/doc/html/pcre_assign_jit_stack.html
index bbf5ebd..8bdc3dd 100644
--- a/doc/html/pcre_assign_jit_stack.html
+++ b/doc/html/pcre_assign_jit_stack.html
@@ -22,15 +22,19 @@ SYNOPSIS
<b>void pcre_assign_jit_stack(pcre_extra *<i>extra</i>,</b>
<b>pcre_jit_callback <i>callback</i>, void *<i>data</i>);</b>
</P>
+<P>
+<b>void pcre16_assign_jit_stack(pcre16_extra *<i>extra</i>,</b>
+<b>pcre16_jit_callback <i>callback</i>, void *<i>data</i>);</b>
+</P>
<br><b>
DESCRIPTION
</b><br>
<P>
This function provides control over the memory used as a stack at runtime by a
-call to <b>pcre_exec()</b> with a pattern that has been successfully compiled
-with JIT optimization. The arguments are:
+call to <b>pcre[16]_exec()</b> with a pattern that has been successfully
+compiled with JIT optimization. The arguments are:
<pre>
- extra the data pointer returned by <b>pcre_study()</b>
+ extra the data pointer returned by <b>pcre[16]_study()</b>
callback a callback function
data a JIT stack or a value to be passed to the callback
function
@@ -42,13 +46,13 @@ the machine stack is used.
</P>
<P>
If <i>callback</i> is NULL and <i>data</i> is not NULL, <i>data</i> must
-be a valid JIT stack, the result of calling <b>pcre_jit_stack_alloc()</b>.
+be a valid JIT stack, the result of calling <b>pcre[16]_jit_stack_alloc()</b>.
</P>
<P>
If <i>callback</i> not NULL, it is called with <i>data</i> as an argument at
the start of matching, in order to set up a JIT stack. If the result is NULL,
the internal 32K stack is used; otherwise the return value must be a valid JIT
-stack, the result of calling <b>pcre_jit_stack_alloc()</b>.
+stack, the result of calling <b>pcre[16]_jit_stack_alloc()</b>.
</P>
<P>
You may safely assign the same JIT stack to multiple patterns, as long as they
diff --git a/doc/html/pcre_compile.html b/doc/html/pcre_compile.html
index 221351b..1ebdb68 100644
--- a/doc/html/pcre_compile.html
+++ b/doc/html/pcre_compile.html
@@ -23,13 +23,18 @@ SYNOPSIS
<b>const char **<i>errptr</i>, int *<i>erroffset</i>,</b>
<b>const unsigned char *<i>tableptr</i>);</b>
</P>
+<P>
+<b>pcre16 *pcre16_compile(PCRE_SPTR16 <i>pattern</i>, int <i>options</i>,</b>
+<b>const char **<i>errptr</i>, int *<i>erroffset</i>,</b>
+<b>const unsigned char *<i>tableptr</i>);</b>
+</P>
<br><b>
DESCRIPTION
</b><br>
<P>
This function compiles a regular expression into an internal form. It is the
-same as <b>pcre_compile2()</b>, except for the absence of the <i>errorcodeptr</i>
-argument. Its arguments are:
+same as <b>pcre[16]_compile2()</b>, except for the absence of the
+<i>errorcodeptr</i> argument. Its arguments are:
<pre>
<i>pattern</i> A zero-terminated string containing the
regular expression to be compiled
@@ -63,15 +68,19 @@ The option bits are:
PCRE_NEWLINE_LF Set LF as the newline sequence
PCRE_NO_AUTO_CAPTURE Disable numbered capturing paren-
theses (named ones available)
+ PCRE_NO_UTF16_CHECK Do not check the pattern for UTF-16
+ validity (only relevant if
+ PCRE_UTF16 is set)
PCRE_NO_UTF8_CHECK Do not check the pattern for UTF-8
validity (only relevant if
PCRE_UTF8 is set)
PCRE_UCP Use Unicode properties for \d, \w, etc.
PCRE_UNGREEDY Invert greediness of quantifiers
- PCRE_UTF8 Run in UTF-8 mode
+ PCRE_UTF16 Run in <b>pcre16_compile()</b> UTF-16 mode
+ PCRE_UTF8 Run in <b>pcre_compile()</b> UTF-8 mode
</pre>
-PCRE must be built with UTF-8 support in order to use PCRE_UTF8 and
-PCRE_NO_UTF8_CHECK, and with UCP support if PCRE_UCP is used.
+PCRE must be built with UTF support in order to use PCRE_UTF8/16 and
+PCRE_NO_UTF8/16_CHECK, and with UCP support if PCRE_UCP is used.
</P>
<P>
The yield of the function is a pointer to a private data structure that
diff --git a/doc/html/pcre_compile2.html b/doc/html/pcre_compile2.html
index f27fffd..c3f3ade 100644
--- a/doc/html/pcre_compile2.html
+++ b/doc/html/pcre_compile2.html
@@ -24,13 +24,19 @@ SYNOPSIS
<b>const char **<i>errptr</i>, int *<i>erroffset</i>,</b>
<b>const unsigned char *<i>tableptr</i>);</b>
</P>
+<P>
+<b>pcre16 *pcre16_compile2(PCRE_SPTR16 <i>pattern</i>, int <i>options</i>,</b>
+<b>int *<i>errorcodeptr</i>,</b>
+<b>const char **<i>errptr</i>, int *<i>erroffset</i>,</b>
+<b>const unsigned char *<i>tableptr</i>);</b>
+</P>
<br><b>
DESCRIPTION
</b><br>
<P>
This function compiles a regular expression into an internal form. It is the
-same as <b>pcre_compile()</b>, except for the addition of the <i>errorcodeptr</i>
-argument. The arguments are:
+same as <b>pcre[16]_compile()</b>, except for the addition of the
+<i>errorcodeptr</i> argument. The arguments are:
<pre>
<i>pattern</i> A zero-terminated string containing the
regular expression to be compiled
@@ -65,15 +71,19 @@ The option bits are:
PCRE_NEWLINE_LF Set LF as the newline sequence
PCRE_NO_AUTO_CAPTURE Disable numbered capturing paren-
theses (named ones available)
+ PCRE_NO_UTF16_CHECK Do not check the pattern for UTF-16
+ validity (only relevant if
+ PCRE_UTF16 is set)
PCRE_NO_UTF8_CHECK Do not check the pattern for UTF-8
validity (only relevant if
PCRE_UTF8 is set)
PCRE_UCP Use Unicode properties for \d, \w, etc.
PCRE_UNGREEDY Invert greediness of quantifiers
- PCRE_UTF8 Run in UTF-8 mode
+ PCRE_UTF16 Run <b>pcre16_compile()</b> in UTF-16 mode
+ PCRE_UTF8 Run <b>pcre_compile()</b> in UTF-8 mode
</pre>
-PCRE must be built with UTF-8 support in order to use PCRE_UTF8 and
-PCRE_NO_UTF8_CHECK, and with UCP support if PCRE_UCP is used.
+PCRE must be built with UTF support in order to use PCRE_UTF8/16 and
+PCRE_NO_UTF8/16_CHECK, and with UCP support if PCRE_UCP is used.
</P>
<P>
The yield of the function is a pointer to a private data structure that
diff --git a/doc/html/pcre_config.html b/doc/html/pcre_config.html
index a18a2e0..31747b0 100644
--- a/doc/html/pcre_config.html
+++ b/doc/html/pcre_config.html
@@ -21,6 +21,9 @@ SYNOPSIS
<P>
<b>int pcre_config(int <i>what</i>, void *<i>where</i>);</b>
</P>
+<P>
+<b>int pcre16_config(int <i>what</i>, void *<i>where</i>);</b>
+</P>
<br><b>
DESCRIPTION
</b><br>
@@ -55,12 +58,17 @@ point to an unsigned long integer. The available codes are:
Threshold of return slots, above which
<b>malloc()</b> is used by the POSIX API
PCRE_CONFIG_STACKRECURSE Recursion implementation (1=stack 0=heap)
- PCRE_CONFIG_UTF8 Availability of UTF-8 support (1=yes 0=no)
+ PCRE_CONFIG_UTF16 Availability of UTF-16 support (1=yes
+ 0=no); option for <b>pcre16_config()</b>
+ PCRE_CONFIG_UTF8 Availability of UTF-8 support (1=yes 0=no);
+ option for <b>pcre_config()</b>
PCRE_CONFIG_UNICODE_PROPERTIES
Availability of Unicode property support
(1=yes 0=no)
</pre>
-The function yields 0 on success or PCRE_ERROR_BADOPTION otherwise.
+The function yields 0 on success or PCRE_ERROR_BADOPTION otherwise. That error
+is also given if PCRE_CONFIG_UTF16 is passed to <b>pcre_config()</b> or if
+PCRE_CONFIG_UTF8 is passed to <b>pcre16_config()</b>.
</P>
<P>
There is a complete description of the PCRE native API in the
diff --git a/doc/html/pcre_copy_named_substring.html b/doc/html/pcre_copy_named_substring.html
index 2185518..40293e5 100644
--- a/doc/html/pcre_copy_named_substring.html
+++ b/doc/html/pcre_copy_named_substring.html
@@ -24,6 +24,12 @@ SYNOPSIS
<b>int <i>stringcount</i>, const char *<i>stringname</i>,</b>
<b>char *<i>buffer</i>, int <i>buffersize</i>);</b>
</P>
+<P>
+<b>int pcre16_copy_named_substring(const pcre16 *<i>code</i>,</b>
+<b>PCRE_SPTR16 <i>subject</i>, int *<i>ovector</i>,</b>
+<b>int <i>stringcount</i>, PCRE_SPTR16 <i>stringname</i>,</b>
+<b>PCRE_UCHAR16 *<i>buffer</i>, int <i>buffersize</i>);</b>
+</P>
<br><b>
DESCRIPTION
</b><br>
@@ -33,8 +39,8 @@ by name, into a given buffer. The arguments are:
<pre>
<i>code</i> Pattern that was successfully matched
<i>subject</i> Subject that has been successfully matched
- <i>ovector</i> Offset vector that <b>pcre_exec()</b> used
- <i>stringcount</i> Value returned by <b>pcre_exec()</b>
+ <i>ovector</i> Offset vector that <b>pcre[16]_exec()</b> used
+ <i>stringcount</i> Value returned by <b>pcre[16]_exec()</b>
<i>stringname</i> Name of the required substring
<i>buffer</i> Buffer to receive the string
<i>buffersize</i> Size of buffer
diff --git a/doc/html/pcre_copy_substring.html b/doc/html/pcre_copy_substring.html
index b7d2341..12a5db4 100644
--- a/doc/html/pcre_copy_substring.html
+++ b/doc/html/pcre_copy_substring.html
@@ -23,6 +23,11 @@ SYNOPSIS
<b>int <i>stringcount</i>, int <i>stringnumber</i>, char *<i>buffer</i>,</b>
<b>int <i>buffersize</i>);</b>
</P>
+<P>
+<b>int pcre16_copy_substring(PCRE_SPTR16 <i>subject</i>, int *<i>ovector</i>,</b>
+<b>int <i>stringcount</i>, int <i>stringnumber</i>, PCRE_UCHAR16 *<i>buffer</i>,</b>
+<b>int <i>buffersize</i>);</b>
+</P>
<br><b>
DESCRIPTION
</b><br>
@@ -31,8 +36,8 @@ This is a convenience function for extracting a captured substring into a given
buffer. The arguments are:
<pre>
<i>subject</i> Subject that has been successfully matched
- <i>ovector</i> Offset vector that <b>pcre_exec()</b> used
- <i>stringcount</i> Value returned by <b>pcre_exec()</b>
+ <i>ovector</i> Offset vector that <b>pcre[16]_exec()</b> used
+ <i>stringcount</i> Value returned by <b>pcre[16]_exec()</b>
<i>stringnumber</i> Number of the required substring
<i>buffer</i> Buffer to receive the string
<i>buffersize</i> Size of buffer
diff --git a/doc/html/pcre_dfa_exec.html b/doc/html/pcre_dfa_exec.html
index d0ec360..76a1baa 100644
--- a/doc/html/pcre_dfa_exec.html
+++ b/doc/html/pcre_dfa_exec.html
@@ -24,6 +24,12 @@ SYNOPSIS
<b>int <i>options</i>, int *<i>ovector</i>, int <i>ovecsize</i>,</b>
<b>int *<i>workspace</i>, int <i>wscount</i>);</b>
</P>
+<P>
+<b>int pcre16_dfa_exec(const pcre16 *<i>code</i>, const pcre16_extra *<i>extra</i>,</b>
+<b>PCRE_SPTR16 <i>subject</i>, int <i>length</i>, int <i>startoffset</i>,</b>
+<b>int <i>options</i>, int *<i>ovector</i>, int <i>ovecsize</i>,</b>
+<b>int *<i>workspace</i>, int <i>wscount</i>);</b>
+</P>
<br><b>
DESCRIPTION
</b><br>
@@ -31,10 +37,11 @@ DESCRIPTION
This function matches a compiled regular expression against a given subject
string, using an alternative matching algorithm that scans the subject string
just once (<i>not</i> Perl-compatible). Note that the main, Perl-compatible,
-matching function is <b>pcre_exec()</b>. The arguments for this function are:
+matching function is <b>pcre[16]_exec()</b>. The arguments for this function
+are:
<pre>
<i>code</i> Points to the compiled pattern
- <i>extra</i> Points to an associated <b>pcre_extra</b> structure,
+ <i>extra</i> Points to an associated <b>pcre[16]_extra</b> structure,
or is NULL
<i>subject</i> Points to the subject string
<i>length</i> Length of the subject string, in bytes
@@ -62,6 +69,9 @@ The options are:
PCRE_NOTEMPTY_ATSTART An empty string at the start of the subject
is not a valid match
PCRE_NO_START_OPTIMIZE Do not do "start-match" optimizations
+ PCRE_NO_UTF16_CHECK Do not check the subject for UTF-16
+ validity (only relevant if PCRE_UTF16
+ was set at compile time)
PCRE_NO_UTF8_CHECK Do not check the subject for UTF-8
validity (only relevant if PCRE_UTF8
was set at compile time)
@@ -80,10 +90,10 @@ documentation. For details of partial matching, see the
page.
</P>
<P>
-A <b>pcre_extra</b> structure contains the following fields:
+A <b>pcre[16]_extra</b> structure contains the following fields:
<pre>
<i>flags</i> Bits indicating which fields are set
- <i>study_data</i> Opaque data from <b>pcre_study()</b>
+ <i>study_data</i> Opaque data from <b>pcre[16]_study()</b>
<i>match_limit</i> Limit on internal resource use
<i>match_limit_recursion</i> Limit on internal recursion depth
<i>callout_data</i> Opaque data passed back to callouts
diff --git a/doc/html/pcre_exec.html b/doc/html/pcre_exec.html
index e5a0b62..98f742f 100644
--- a/doc/html/pcre_exec.html
+++ b/doc/html/pcre_exec.html
@@ -23,6 +23,11 @@ SYNOPSIS
<b>const char *<i>subject</i>, int <i>length</i>, int <i>startoffset</i>,</b>
<b>int <i>options</i>, int *<i>ovector</i>, int <i>ovecsize</i>);</b>
</P>
+<P>
+<b>int pcre16_exec(const pcre16 *<i>code</i>, const pcre16_extra *<i>extra</i>,</b>
+<b>PCRE_SPTR16 <i>subject</i>, int <i>length</i>, int <i>startoffset</i>,</b>
+<b>int <i>options</i>, int *<i>ovector</i>, int <i>ovecsize</i>);</b>
+</P>
<br><b>
DESCRIPTION
</b><br>
@@ -32,7 +37,7 @@ string, using a matching algorithm that is similar to Perl's. It returns
offsets to captured substrings. Its arguments are:
<pre>
<i>code</i> Points to the compiled pattern
- <i>extra</i> Points to an associated <b>pcre_extra</b> structure,
+ <i>extra</i> Points to an associated <b>pcre[16]_extra</b> structure,
or is NULL
<i>subject</i> Points to the subject string
<i>length</i> Length of the subject string, in bytes
@@ -58,6 +63,9 @@ The options are:
PCRE_NOTEMPTY_ATSTART An empty string at the start of the subject
is not a valid match
PCRE_NO_START_OPTIMIZE Do not do "start-match" optimizations
+ PCRE_NO_UTF16_CHECK Do not check the subject for UTF-16
+ validity (only relevant if PCRE_UTF16
+ was set at compile time)
PCRE_NO_UTF8_CHECK Do not check the subject for UTF-8
validity (only relevant if PCRE_UTF8
was set at compile time)
@@ -71,7 +79,7 @@ For details of partial matching, see the
page. A <b>pcre_extra</b> structure contains the following fields:
<pre>
<i>flags</i> Bits indicating which fields are set
- <i>study_data</i> Opaque data from <b>pcre_study()</b>
+ <i>study_data</i> Opaque data from <b>pcre[16]_study()</b>
<i>match_limit</i> Limit on internal resource use
<i>match_limit_recursion</i> Limit on internal recursion depth
<i>callout_data</i> Opaque data passed back to callouts
diff --git a/doc/html/pcre_free_study.html b/doc/html/pcre_free_study.html
index 8319a48..1bbcffe 100644
--- a/doc/html/pcre_free_study.html
+++ b/doc/html/pcre_free_study.html
@@ -21,12 +21,15 @@ SYNOPSIS
<P>
<b>void pcre_free_study(pcre_extra *<i>extra</i>);</b>
</P>
+<P>
+<b>void pcre16_free_study(pcre16_extra *<i>extra</i>);</b>
+</P>
<br><b>
DESCRIPTION
</b><br>
<P>
This function is used to free the memory used for the data generated by a call
-to <b>pcre_study()</b> when it is no longer needed. The argument must be the
+to <b>pcre[16]_study()</b> when it is no longer needed. The argument must be the
result of such a call.
</P>
<P>
diff --git a/doc/html/pcre_free_substring.html b/doc/html/pcre_free_substring.html
index fe62614..d820745 100644
--- a/doc/html/pcre_free_substring.html
+++ b/doc/html/pcre_free_substring.html
@@ -21,13 +21,16 @@ SYNOPSIS
<P>
<b>void pcre_free_substring(const char *<i>stringptr</i>);</b>
</P>
+<P>
+<b>void pcre16_free_substring(PCRE_SPTR16 <i>stringptr</i>);</b>
+</P>
<br><b>
DESCRIPTION
</b><br>
<P>
This is a convenience function for freeing the store obtained by a previous
-call to <b>pcre_get_substring()</b> or <b>pcre_get_named_substring()</b>. Its
-only argument is a pointer to the string.
+call to <b>pcre[16]_get_substring()</b> or <b>pcre[16]_get_named_substring()</b>.
+Its only argument is a pointer to the string.
</P>
<P>
There is a complete description of the PCRE native API in the
diff --git a/doc/html/pcre_free_substring_list.html b/doc/html/pcre_free_substring_list.html
index a92c960..26e2daf 100644
--- a/doc/html/pcre_free_substring_list.html
+++ b/doc/html/pcre_free_substring_list.html
@@ -21,13 +21,16 @@ SYNOPSIS
<P>
<b>void pcre_free_substring_list(const char **<i>stringptr</i>);</b>
</P>
+<P>
+<b>void pcre16_free_substring_list(PCRE_SPTR16 *<i>stringptr</i>);</b>
+</P>
<br><b>
DESCRIPTION
</b><br>
<P>
This is a convenience function for freeing the store obtained by a previous
-call to <b>pcre_get_substring_list()</b>. Its only argument is a pointer to the
-list of string pointers.
+call to <b>pcre[16]_get_substring_list()</b>. Its only argument is a pointer to
+the list of string pointers.
</P>
<P>
There is a complete description of the PCRE native API in the
diff --git a/doc/html/pcre_fullinfo.html b/doc/html/pcre_fullinfo.html
index 33cfef4..49186dd 100644
--- a/doc/html/pcre_fullinfo.html
+++ b/doc/html/pcre_fullinfo.html
@@ -22,6 +22,10 @@ SYNOPSIS
<b>int pcre_fullinfo(const pcre *<i>code</i>, const pcre_extra *<i>extra</i>,</b>
<b>int <i>what</i>, void *<i>where</i>);</b>
</P>
+<P>
+<b>int pcre16_fullinfo(const pcre16 *<i>code</i>, const pcre16_extra *<i>extra</i>,</b>
+<b>int <i>what</i>, void *<i>where</i>);</b>
+</P>
<br><b>
DESCRIPTION
</b><br>
@@ -29,7 +33,7 @@ DESCRIPTION
This function returns information about a compiled pattern. Its arguments are:
<pre>
<i>code</i> Compiled regular expression
- <i>extra</i> Result of <b>pcre_study()</b> or NULL
+ <i>extra</i> Result of <b>pcre[16]_study()</b> or NULL
<i>what</i> What information is required
<i>where</i> Where to put the information
</pre>
@@ -38,15 +42,16 @@ The following information is available:
PCRE_INFO_BACKREFMAX Number of highest back reference
PCRE_INFO_CAPTURECOUNT Number of capturing subpatterns
PCRE_INFO_DEFAULT_TABLES Pointer to default tables
- PCRE_INFO_FIRSTBYTE Fixed first byte for a match, or
+ PCRE_INFO_FIRSTBYTE Fixed first data unit for a match, or
-1 for start of string
or after newline, or
-2 otherwise
- PCRE_INFO_FIRSTTABLE Table of first bytes (after studying)
+ PCRE_INFO_FIRSTTABLE Table of first data units (after studying)
PCRE_INFO_HASCRORLF Return 1 if explicit CR or LF matches exist
PCRE_INFO_JCHANGED Return 1 if (?J) or (?-J) was used
PCRE_INFO_JIT Return 1 after successful JIT compilation
- PCRE_INFO_LASTLITERAL Literal last byte required
+ PCRE_INFO_JITSIZE Size of JIT compiled code
+ PCRE_INFO_LASTLITERAL Literal last data unit required
PCRE_INFO_MINLENGTH Lower bound length of matching strings
PCRE_INFO_NAMECOUNT Number of named subpatterns
PCRE_INFO_NAMEENTRYSIZE Size of name table entry
@@ -62,7 +67,8 @@ following <i>what</i> values:
<pre>
PCRE_INFO_DEFAULT_TABLES const unsigned char *
PCRE_INFO_FIRSTTABLE const unsigned char *
- PCRE_INFO_NAMETABLE const unsigned char *
+ PCRE_INFO_NAMETABLE PCRE_SPTR16 (16-bit library)
+ PCRE_INFO_NAMETABLE const unsigned char * (8-bit library)
PCRE_INFO_OPTIONS unsigned long int
PCRE_INFO_SIZE size_t
</pre>
diff --git a/doc/html/pcre_get_named_substring.html b/doc/html/pcre_get_named_substring.html
index 24dc058..5eea87c 100644
--- a/doc/html/pcre_get_named_substring.html
+++ b/doc/html/pcre_get_named_substring.html
@@ -24,6 +24,12 @@ SYNOPSIS
<b>int <i>stringcount</i>, const char *<i>stringname</i>,</b>
<b>const char **<i>stringptr</i>);</b>
</P>
+<P>
+<b>int pcre16_get_named_substring(const pcre16 *<i>code</i>,</b>
+<b>PCRE_SPTR16 <i>subject</i>, int *<i>ovector</i>,</b>
+<b>int <i>stringcount</i>, PCRE_SPTR16 <i>stringname</i>,</b>
+<b>PCRE_SPTR16 *<i>stringptr</i>);</b>
+</P>
<br><b>
DESCRIPTION
</b><br>
@@ -33,16 +39,17 @@ arguments are:
<pre>
<i>code</i> Compiled pattern
<i>subject</i> Subject that has been successfully matched
- <i>ovector</i> Offset vector that <b>pcre_exec()</b> used
- <i>stringcount</i> Value returned by <b>pcre_exec()</b>
+ <i>ovector</i> Offset vector that <b>pcre[16]_exec()</b> used
+ <i>stringcount</i> Value returned by <b>pcre[16]_exec()</b>
<i>stringname</i> Name of the required substring
<i>stringptr</i> Where to put the string pointer
</pre>
The memory in which the substring is placed is obtained by calling
-<b>pcre_malloc()</b>. The convenience function <b>pcre_free_substring()</b> can
-be used to free it when it is no longer needed. The yield of the function is
-the length of the extracted substring, PCRE_ERROR_NOMEMORY if sufficient memory
-could not be obtained, or PCRE_ERROR_NOSUBSTRING if the string name is invalid.
+<b>pcre[16]_malloc()</b>. The convenience function
+<b>pcre[16]_free_substring()</b> can be used to free it when it is no longer
+needed. The yield of the function is the length of the extracted substring,
+PCRE_ERROR_NOMEMORY if sufficient memory could not be obtained, or
+PCRE_ERROR_NOSUBSTRING if the string name is invalid.
</P>
<P>
There is a complete description of the PCRE native API in the
diff --git a/doc/html/pcre_get_stringnumber.html b/doc/html/pcre_get_stringnumber.html
index 43af3aa..1c9483a 100644
--- a/doc/html/pcre_get_stringnumber.html
+++ b/doc/html/pcre_get_stringnumber.html
@@ -22,6 +22,10 @@ SYNOPSIS
<b>int pcre_get_stringnumber(const pcre *<i>code</i>,</b>
<b>const char *<i>name</i>);</b>
</P>
+<P>
+<b>int pcre16_get_stringnumber(const pcre16 *<i>code</i>,</b>
+<b>PCRE_SPTR16 <i>name</i>);</b>
+</P>
<br><b>
DESCRIPTION
</b><br>
@@ -35,8 +39,8 @@ parenthesis in a compiled pattern. Its arguments are:
The yield of the function is the number of the parenthesis if the name is
found, or PCRE_ERROR_NOSUBSTRING otherwise. When duplicate names are allowed
(PCRE_DUPNAMES is set), it is not defined which of the numbers is returned by
-<b>pcre_get_stringnumber()</b>. You can obtain the complete list by calling
-<b>pcre_get_stringtable_entries()</b>.
+<b>pcre[16]_get_stringnumber()</b>. You can obtain the complete list by calling
+<b>pcre[16]_get_stringtable_entries()</b>.
</P>
<P>
There is a complete description of the PCRE native API in the
diff --git a/doc/html/pcre_get_stringtable_entries.html b/doc/html/pcre_get_stringtable_entries.html
index dc20ffd..954fb5b 100644
--- a/doc/html/pcre_get_stringtable_entries.html
+++ b/doc/html/pcre_get_stringtable_entries.html
@@ -22,6 +22,10 @@ SYNOPSIS
<b>int pcre_get_stringtable_entries(const pcre *<i>code</i>,</b>
<b>const char *<i>name</i>, char **<i>first</i>, char **<i>last</i>);</b>
</P>
+<P>
+<b>int pcre16_get_stringtable_entries(const pcre16 *<i>code</i>,</b>
+<b>PCRE_SPTR16 <i>name</i>, PCRE_UCHAR16 **<i>first</i>, PCRE_UCHAR16 **<i>last</i>);</b>
+</P>
<br><b>
DESCRIPTION
</b><br>
@@ -29,7 +33,7 @@ DESCRIPTION
This convenience function finds, for a compiled pattern, the first and last
entries for a given name in the table that translates capturing parenthesis
names into numbers. When names are required to be unique (PCRE_DUPNAMES is
-<i>not</i> set), it is usually easier to use <b>pcre_get_stringnumber()</b>
+<i>not</i> set), it is usually easier to use <b>pcre[16]_get_stringnumber()</b>
instead.
<pre>
<i>code</i> Compiled regular expression
diff --git a/doc/html/pcre_get_substring.html b/doc/html/pcre_get_substring.html
index 9b40e4d..279cee6 100644
--- a/doc/html/pcre_get_substring.html
+++ b/doc/html/pcre_get_substring.html
@@ -23,6 +23,11 @@ SYNOPSIS
<b>int <i>stringcount</i>, int <i>stringnumber</i>,</b>
<b>const char **<i>stringptr</i>);</b>
</P>
+<P>
+<b>int pcre16_get_substring(PCRE_SPTR16 <i>subject</i>, int *<i>ovector</i>,</b>
+<b>int <i>stringcount</i>, int <i>stringnumber</i>,</b>
+<b>PCRE_SPTR16 *<i>stringptr</i>);</b>
+</P>
<br><b>
DESCRIPTION
</b><br>
@@ -31,16 +36,17 @@ This is a convenience function for extracting a captured substring. The
arguments are:
<pre>
<i>subject</i> Subject that has been successfully matched
- <i>ovector</i> Offset vector that <b>pcre_exec()</b> used
- <i>stringcount</i> Value returned by <b>pcre_exec()</b>
+ <i>ovector</i> Offset vector that <b>pcre[16]_exec()</b> used
+ <i>stringcount</i> Value returned by <b>pcre[16]_exec()</b>
<i>stringnumber</i> Number of the required substring
<i>stringptr</i> Where to put the string pointer
</pre>
The memory in which the substring is placed is obtained by calling
-<b>pcre_malloc()</b>. The convenience function <b>pcre_free_substring()</b> can
-be used to free it when it is no longer needed. The yield of the function is
-the length of the substring, PCRE_ERROR_NOMEMORY if sufficient memory could not
-be obtained, or PCRE_ERROR_NOSUBSTRING if the string number is invalid.
+<b>pcre[16]_malloc()</b>. The convenience function
+<b>pcre[16]_free_substring()</b> can be used to free it when it is no longer
+needed. The yield of the function is the length of the substring,
+PCRE_ERROR_NOMEMORY if sufficient memory could not be obtained, or
+PCRE_ERROR_NOSUBSTRING if the string number is invalid.
</P>
<P>
There is a complete description of the PCRE native API in the
diff --git a/doc/html/pcre_get_substring_list.html b/doc/html/pcre_get_substring_list.html
index 617a315..178b22e 100644
--- a/doc/html/pcre_get_substring_list.html
+++ b/doc/html/pcre_get_substring_list.html
@@ -22,6 +22,10 @@ SYNOPSIS
<b>int pcre_get_substring_list(const char *<i>subject</i>,</b>
<b>int *<i>ovector</i>, int <i>stringcount</i>, const char ***<i>listptr</i>);</b>
</P>
+<P>
+<b>int pcre16_get_substring_list(PCRE_SPTR16 <i>subject</i>,</b>
+<b>int *<i>ovector</i>, int <i>stringcount</i>, PCRE_SPTR16 **<i>listptr</i>);</b>
+</P>
<br><b>
DESCRIPTION
</b><br>
@@ -30,17 +34,17 @@ This is a convenience function for extracting a list of all the captured
substrings. The arguments are:
<pre>
<i>subject</i> Subject that has been successfully matched
- <i>ovector</i> Offset vector that <b>pcre_exec</b> used
- <i>stringcount</i> Value returned by <b>pcre_exec</b>
+ <i>ovector</i> Offset vector that <b>pcre[16]_exec</b> used
+ <i>stringcount</i> Value returned by <b>pcre[16]_exec</b>
<i>listptr</i> Where to put a pointer to the list
</pre>
The memory in which the substrings and the list are placed is obtained by
-calling <b>pcre_malloc()</b>. The convenience function
-<b>pcre_free_substring_list()</b> can be used to free it when it is no longer
-needed. A pointer to a list of pointers is put in the variable whose address is
-in <i>listptr</i>. The list is terminated by a NULL pointer. The yield of the
-function is zero on success or PCRE_ERROR_NOMEMORY if sufficient memory could
-not be obtained.
+calling <b>pcre[16]_malloc()</b>. The convenience function
+<b>pcre[16]_free_substring_list()</b> can be used to free it when it is no
+longer needed. A pointer to a list of pointers is put in the variable whose
+address is in <i>listptr</i>. The list is terminated by a NULL pointer. The
+yield of the function is zero on success or PCRE_ERROR_NOMEMORY if sufficient
+memory could not be obtained.
</P>
<P>
There is a complete description of the PCRE native API in the
diff --git a/doc/html/pcre_info.html b/doc/html/pcre_info.html
deleted file mode 100644
index 6693ffe..0000000
--- a/doc/html/pcre_info.html
+++ /dev/null
@@ -1,39 +0,0 @@
-<html>
-<head>
-<title>pcre_info specification</title>
-</head>
-<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
-<h1>pcre_info man page</h1>
-<p>
-Return to the <a href="index.html">PCRE index page</a>.
-</p>
-<p>
-This page is part of the PCRE HTML documentation. It was generated automatically
-from the original man page. If there is any nonsense in it, please consult the
-man page, in case the conversion went wrong.
-<br>
-<br><b>
-SYNOPSIS
-</b><br>
-<P>
-<b>#include &#60;pcre.h&#62;</b>
-</P>
-<P>
-<b>int pcre_info(const pcre *<i>code</i>, int *<i>optptr</i>, int</b>
-<b>*<i>firstcharptr</i>);</b>
-</P>
-<br><b>
-DESCRIPTION
-</b><br>
-<P>
-This function is obsolete. You should be using <b>pcre_fullinfo()</b> instead.
-</P>
-<P>
-There is a complete description of the PCRE native API in the
-<a href="pcreapi.html"><b>pcreapi</b></a>
-page and a description of the POSIX API in the
-<a href="pcreposix.html"><b>pcreposix</b></a>
-page.
-<p>
-Return to the <a href="index.html">PCRE index page</a>.
-</p>
diff --git a/doc/html/pcre_jit_stack_alloc.html b/doc/html/pcre_jit_stack_alloc.html
index 60a6cf1..adcb3c7 100644
--- a/doc/html/pcre_jit_stack_alloc.html
+++ b/doc/html/pcre_jit_stack_alloc.html
@@ -22,14 +22,17 @@ SYNOPSIS
<b>pcre_jit_stack *pcre_jit_stack_alloc(int <i>startsize</i>,</b>
<b>int <i>maxsize</i>);</b>
</P>
+<P>
+<b>pcre16_jit_stack *pcre16_jit_stack_alloc(int <i>startsize</i>, int <i>maxsize</i>);</b>
+</P>
<br><b>
DESCRIPTION
</b><br>
<P>
This function is used to create a stack for use by the code compiled by the JIT
-optimization of <b>pcre_study()</b>. The arguments are a starting size for the
-stack, and a maximum size to which it is allowed to grow. The result can be
-passed to the JIT runtime code by <b>pcre_assign_jit_stack()</b>, or that
+optimization of <b>pcre[16]_study()</b>. The arguments are a starting size for
+the stack, and a maximum size to which it is allowed to grow. The result can be
+passed to the JIT runtime code by <b>pcre[16]_assign_jit_stack()</b>, or that
function can set up a callback for obtaining a stack. A maximum stack size of
512K to 1M should be more than enough for any pattern. For more details, see
the
diff --git a/doc/html/pcre_jit_stack_free.html b/doc/html/pcre_jit_stack_free.html
index cce389f..ecbf5d0 100644
--- a/doc/html/pcre_jit_stack_free.html
+++ b/doc/html/pcre_jit_stack_free.html
@@ -21,13 +21,16 @@ SYNOPSIS
<P>
<b>void pcre_jit_stack_free(pcre_jit_stack *<i>stack</i>);</b>
</P>
+<P>
+<b>void pcre16_jit_stack_free(pcre16_jit_stack *<i>stack</i>);</b>
+</P>
<br><b>
DESCRIPTION
</b><br>
<P>
This function is used to free a JIT stack that was created by
-<b>pcre_jit_stack_alloc()</b> when it is no longer needed. For more details, see
-the
+<b>pcre[16]_jit_stack_alloc()</b> when it is no longer needed. For more details,
+see the
<a href="pcrejit.html"><b>pcrejit</b></a>
page.
</P>
diff --git a/doc/html/pcre_maketables.html b/doc/html/pcre_maketables.html
index cf8d69e..a4be6b1 100644
--- a/doc/html/pcre_maketables.html
+++ b/doc/html/pcre_maketables.html
@@ -21,15 +21,18 @@ SYNOPSIS
<P>
<b>const unsigned char *pcre_maketables(void);</b>
</P>
+<P>
+<b>const unsigned char *pcre16_maketables(void);</b>
+</P>
<br><b>
DESCRIPTION
</b><br>
<P>
This function builds a set of character tables for character values less than
-256. These can be passed to <b>pcre_compile()</b> to override PCRE's internal,
-built-in tables (which were made by <b>pcre_maketables()</b> when PCRE was
-compiled). You might want to do this if you are using a non-standard locale.
-The function yields a pointer to the tables.
+256. These can be passed to <b>pcre[16]_compile()</b> to override PCRE's
+internal, built-in tables (which were made by <b>pcre[16]_maketables()</b> when
+PCRE was compiled). You might want to do this if you are using a non-standard
+locale. The function yields a pointer to the tables.
</P>
<P>
There is a complete description of the PCRE native API in the
diff --git a/doc/html/pcre_pattern_to_host_byte_order.html b/doc/html/pcre_pattern_to_host_byte_order.html
new file mode 100644
index 0000000..3c311de
--- /dev/null
+++ b/doc/html/pcre_pattern_to_host_byte_order.html
@@ -0,0 +1,54 @@
+<html>
+<head>
+<title>pcre_pattern_to_host_byte_order specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>pcre_pattern_to_host_byte_order man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+<br><b>
+SYNOPSIS
+</b><br>
+<P>
+<b>#include &#60;pcre.h&#62;</b>
+</P>
+<P>
+<b>int pcre_pattern_to_host_byte_order(pcre *<i>code</i>,</b>
+<b>pcre_extra *<i>extra</i>, const unsigned char *<i>tables</i>); </b>
+</P>
+<P>
+<b>int pcre16_pattern_to_host_byte_order(pcre16 *<i>code</i>,</b>
+<b>pcre16_extra *<i>extra</i>, const unsigned char *<i>tables</i>);</b>
+</P>
+<br><b>
+DESCRIPTION
+</b><br>
+<P>
+This function ensures that the bytes in 2-byte and 4-byte values in a compiled
+pattern are in the correct order for the current host. It is useful when a
+pattern that has been compiled on one host is transferred to another that might
+have different endianness. The arguments are:
+<pre>
+ <i>code</i> A compiled regular expression
+ <i>extra</i> Points to an associated <b>pcre[16]_extra</b> structure,
+ or is NULL
+ <i>tables</i> Pointer to character tables, or NULL to
+ set the built-in default
+</pre>
+The result is 0 for success, a negative PCRE_ERROR_xxx value otherwise.
+</P>
+<P>
+There is a complete description of the PCRE native API in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page and a description of the POSIX API in the
+<a href="pcreposix.html"><b>pcreposix</b></a>
+page.
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
diff --git a/doc/html/pcre_refcount.html b/doc/html/pcre_refcount.html
index b748df2..a2af821 100644
--- a/doc/html/pcre_refcount.html
+++ b/doc/html/pcre_refcount.html
@@ -21,6 +21,9 @@ SYNOPSIS
<P>
<b>int pcre_refcount(pcre *<i>code</i>, int <i>adjust</i>);</b>
</P>
+<P>
+<b>int pcre16_refcount(pcre16 *<i>code</i>, int <i>adjust</i>);</b>
+</P>
<br><b>
DESCRIPTION
</b><br>
diff --git a/doc/html/pcre_study.html b/doc/html/pcre_study.html
index 3c1cbcc..ab56c62 100644
--- a/doc/html/pcre_study.html
+++ b/doc/html/pcre_study.html
@@ -22,6 +22,10 @@ SYNOPSIS
<b>pcre_extra *pcre_study(const pcre *<i>code</i>, int <i>options</i>,</b>
<b>const char **<i>errptr</i>);</b>
</P>
+<P>
+<b>pcre16_extra *pcre16_study(const pcre16 *<i>code</i>, int <i>options</i>,</b>
+<b>const char **<i>errptr</i>);</b>
+</P>
<br><b>
DESCRIPTION
</b><br>
@@ -30,11 +34,12 @@ This function studies a compiled pattern, to see if additional information can
be extracted that might speed up matching. Its arguments are:
<pre>
<i>code</i> A compiled regular expression
- <i>options</i> Options for <b>pcre_study()</b>
+ <i>options</i> Options for <b>pcre[16]_study()</b>
<i>errptr</i> Where to put an error message
</pre>
If the function succeeds, it returns a value that can be passed to
-<b>pcre_exec()</b> or <b>pcre_dfa_exec()</b> via their <i>extra</i> arguments.
+<b>pcre[16]_exec()</b> or <b>pcre[16]_dfa_exec()</b> via their <i>extra</i>
+arguments.
</P>
<P>
If the function returns NULL, either it could not find any additional
diff --git a/doc/html/pcre_utf16_to_host_byte_order.html b/doc/html/pcre_utf16_to_host_byte_order.html
new file mode 100644
index 0000000..63544f2
--- /dev/null
+++ b/doc/html/pcre_utf16_to_host_byte_order.html
@@ -0,0 +1,57 @@
+<html>
+<head>
+<title>pcre_utf16_to_host_byte_order specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>pcre_utf16_to_host_byte_order man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+<br><b>
+SYNOPSIS
+</b><br>
+<P>
+<b>#include &#60;pcre.h&#62;</b>
+</P>
+<P>
+<b>int pcre16_utf16_to_host_byte_order(PCRE_UCHAR16 *<i>output</i>,</b>
+<b>PCRE_SPTR16 <i>input</i>, int <i>length</i>, int *<i>byte_order</i>, </b>
+<b>int <i>keep_boms</i>);</b>
+</P>
+<br><b>
+DESCRIPTION
+</b><br>
+<P>
+This function, which exists only in the 16-bit library, converts a UTF-16
+string to the correct order for the current host, taking account of any byte
+order marks (BOMs) within the string. Its arguments are:
+<pre>
+ <i>output</i> pointer to output buffer, may be the same as <i>input</i>
+ <i>input</i> pointer to input buffer
+ <i>length</i> number of 16-bit units in the input, or negative for
+ a zero-terminated string
+ <i>byte_order</i> a NULL value or a value of 0 pointed to means start
+ in host byte order
+ <i>keep_boms</i> if non-zero, BOMs are copied to the output string
+</pre>
+The result of the function is the number of 16-bit units placed into the output
+buffer, including the zero terminator if the string was zero-terminated.
+</P>
+<P>
+If <i>byte_order</i> is not NULL, it is set to indicate the byte order that is
+current at the end of the string.
+</P>
+<P>
+There is a complete description of the PCRE native API in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page and a description of the POSIX API in the
+<a href="pcreposix.html"><b>pcreposix</b></a>
+page.
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
diff --git a/doc/html/pcre_version.html b/doc/html/pcre_version.html
index 7bc8f86..6b6a8ab 100644
--- a/doc/html/pcre_version.html
+++ b/doc/html/pcre_version.html
@@ -19,14 +19,18 @@ SYNOPSIS
<b>#include &#60;pcre.h&#62;</b>
</P>
<P>
-<b>char *pcre_version(void);</b>
+<b>const char *pcre_version(void);</b>
+</P>
+<P>
+<b>const char *pcre16_version(void);</b>
</P>
<br><b>
DESCRIPTION
</b><br>
<P>
-This function returns a character string that gives the version number of the
-PCRE library and the date of its release.
+This function (even in the 16-bit library) returns a zero-terminated, 8-bit
+character string that gives the version number of the PCRE library and the date
+of its release.
</P>
<P>
There is a complete description of the PCRE native API in the
diff --git a/doc/html/pcreapi.html b/doc/html/pcreapi.html
index 3cbb6be..e4566a3 100644
--- a/doc/html/pcreapi.html
+++ b/doc/html/pcreapi.html
@@ -14,34 +14,35 @@ man page, in case the conversion went wrong.
<br>
<ul>
<li><a name="TOC1" href="#SEC1">PCRE NATIVE API BASIC FUNCTIONS</a>
-<li><a name="TOC2" href="#SEC2">PCRE NATIVE API AUXILIARY FUNCTIONS</a>
-<li><a name="TOC3" href="#SEC3">PCRE NATIVE API INDIRECTED FUNCTIONS</a>
-<li><a name="TOC4" href="#SEC4">PCRE API OVERVIEW</a>
-<li><a name="TOC5" href="#SEC5">NEWLINES</a>
-<li><a name="TOC6" href="#SEC6">MULTITHREADING</a>
-<li><a name="TOC7" href="#SEC7">SAVING PRECOMPILED PATTERNS FOR LATER USE</a>
-<li><a name="TOC8" href="#SEC8">CHECKING BUILD-TIME OPTIONS</a>
-<li><a name="TOC9" href="#SEC9">COMPILING A PATTERN</a>
-<li><a name="TOC10" href="#SEC10">COMPILATION ERROR CODES</a>
-<li><a name="TOC11" href="#SEC11">STUDYING A PATTERN</a>
-<li><a name="TOC12" href="#SEC12">LOCALE SUPPORT</a>
-<li><a name="TOC13" href="#SEC13">INFORMATION ABOUT A PATTERN</a>
-<li><a name="TOC14" href="#SEC14">OBSOLETE INFO FUNCTION</a>
-<li><a name="TOC15" href="#SEC15">REFERENCE COUNTS</a>
-<li><a name="TOC16" href="#SEC16">MATCHING A PATTERN: THE TRADITIONAL FUNCTION</a>
-<li><a name="TOC17" href="#SEC17">EXTRACTING CAPTURED SUBSTRINGS BY NUMBER</a>
-<li><a name="TOC18" href="#SEC18">EXTRACTING CAPTURED SUBSTRINGS BY NAME</a>
-<li><a name="TOC19" href="#SEC19">DUPLICATE SUBPATTERN NAMES</a>
-<li><a name="TOC20" href="#SEC20">FINDING ALL POSSIBLE MATCHES</a>
-<li><a name="TOC21" href="#SEC21">MATCHING A PATTERN: THE ALTERNATIVE FUNCTION</a>
-<li><a name="TOC22" href="#SEC22">SEE ALSO</a>
-<li><a name="TOC23" href="#SEC23">AUTHOR</a>
-<li><a name="TOC24" href="#SEC24">REVISION</a>
+<li><a name="TOC2" href="#SEC2">PCRE NATIVE API STRING EXTRACTION FUNCTIONS</a>
+<li><a name="TOC3" href="#SEC3">PCRE NATIVE API AUXILIARY FUNCTIONS</a>
+<li><a name="TOC4" href="#SEC4">PCRE NATIVE API INDIRECTED FUNCTIONS</a>
+<li><a name="TOC5" href="#SEC5">PCRE 8-BIT AND 16-BIT LIBRARIES</a>
+<li><a name="TOC6" href="#SEC6">PCRE API OVERVIEW</a>
+<li><a name="TOC7" href="#SEC7">NEWLINES</a>
+<li><a name="TOC8" href="#SEC8">MULTITHREADING</a>
+<li><a name="TOC9" href="#SEC9">SAVING PRECOMPILED PATTERNS FOR LATER USE</a>
+<li><a name="TOC10" href="#SEC10">CHECKING BUILD-TIME OPTIONS</a>
+<li><a name="TOC11" href="#SEC11">COMPILING A PATTERN</a>
+<li><a name="TOC12" href="#SEC12">COMPILATION ERROR CODES</a>
+<li><a name="TOC13" href="#SEC13">STUDYING A PATTERN</a>
+<li><a name="TOC14" href="#SEC14">LOCALE SUPPORT</a>
+<li><a name="TOC15" href="#SEC15">INFORMATION ABOUT A PATTERN</a>
+<li><a name="TOC16" href="#SEC16">REFERENCE COUNTS</a>
+<li><a name="TOC17" href="#SEC17">MATCHING A PATTERN: THE TRADITIONAL FUNCTION</a>
+<li><a name="TOC18" href="#SEC18">EXTRACTING CAPTURED SUBSTRINGS BY NUMBER</a>
+<li><a name="TOC19" href="#SEC19">EXTRACTING CAPTURED SUBSTRINGS BY NAME</a>
+<li><a name="TOC20" href="#SEC20">DUPLICATE SUBPATTERN NAMES</a>
+<li><a name="TOC21" href="#SEC21">FINDING ALL POSSIBLE MATCHES</a>
+<li><a name="TOC22" href="#SEC22">MATCHING A PATTERN: THE ALTERNATIVE FUNCTION</a>
+<li><a name="TOC23" href="#SEC23">SEE ALSO</a>
+<li><a name="TOC24" href="#SEC24">AUTHOR</a>
+<li><a name="TOC25" href="#SEC25">REVISION</a>
</ul>
-<br><a name="SEC1" href="#TOC1">PCRE NATIVE API BASIC FUNCTIONS</a><br>
<P>
<b>#include &#60;pcre.h&#62;</b>
</P>
+<br><a name="SEC1" href="#TOC1">PCRE NATIVE API BASIC FUNCTIONS</a><br>
<P>
<b>pcre *pcre_compile(const char *<i>pattern</i>, int <i>options</i>,</b>
<b>const char **<i>errptr</i>, int *<i>erroffset</i>,</b>
@@ -65,23 +66,13 @@ man page, in case the conversion went wrong.
<b>const char *<i>subject</i>, int <i>length</i>, int <i>startoffset</i>,</b>
<b>int <i>options</i>, int *<i>ovector</i>, int <i>ovecsize</i>);</b>
</P>
-<br><a name="SEC2" href="#TOC1">PCRE NATIVE API AUXILIARY FUNCTIONS</a><br>
-<P>
-<b>pcre_jit_stack *pcre_jit_stack_alloc(int <i>startsize</i>, int <i>maxsize</i>);</b>
-</P>
-<P>
-<b>void pcre_jit_stack_free(pcre_jit_stack *<i>stack</i>);</b>
-</P>
-<P>
-<b>void pcre_assign_jit_stack(pcre_extra *<i>extra</i>,</b>
-<b>pcre_jit_callback <i>callback</i>, void *<i>data</i>);</b>
-</P>
<P>
<b>int pcre_dfa_exec(const pcre *<i>code</i>, const pcre_extra *<i>extra</i>,</b>
<b>const char *<i>subject</i>, int <i>length</i>, int <i>startoffset</i>,</b>
<b>int <i>options</i>, int *<i>ovector</i>, int <i>ovecsize</i>,</b>
<b>int *<i>workspace</i>, int <i>wscount</i>);</b>
</P>
+<br><a name="SEC2" href="#TOC1">PCRE NATIVE API STRING EXTRACTION FUNCTIONS</a><br>
<P>
<b>int pcre_copy_named_substring(const pcre *<i>code</i>,</b>
<b>const char *<i>subject</i>, int *<i>ovector</i>,</b>
@@ -122,6 +113,17 @@ man page, in case the conversion went wrong.
<P>
<b>void pcre_free_substring_list(const char **<i>stringptr</i>);</b>
</P>
+<br><a name="SEC3" href="#TOC1">PCRE NATIVE API AUXILIARY FUNCTIONS</a><br>
+<P>
+<b>pcre_jit_stack *pcre_jit_stack_alloc(int <i>startsize</i>, int <i>maxsize</i>);</b>
+</P>
+<P>
+<b>void pcre_jit_stack_free(pcre_jit_stack *<i>stack</i>);</b>
+</P>
+<P>
+<b>void pcre_assign_jit_stack(pcre_extra *<i>extra</i>,</b>
+<b>pcre_jit_callback <i>callback</i>, void *<i>data</i>);</b>
+</P>
<P>
<b>const unsigned char *pcre_maketables(void);</b>
</P>
@@ -130,19 +132,19 @@ man page, in case the conversion went wrong.
<b>int <i>what</i>, void *<i>where</i>);</b>
</P>
<P>
-<b>int pcre_info(const pcre *<i>code</i>, int *<i>optptr</i>, int</b>
-<b>*<i>firstcharptr</i>);</b>
-</P>
-<P>
<b>int pcre_refcount(pcre *<i>code</i>, int <i>adjust</i>);</b>
</P>
<P>
<b>int pcre_config(int <i>what</i>, void *<i>where</i>);</b>
</P>
<P>
-<b>char *pcre_version(void);</b>
+<b>const char *pcre_version(void);</b>
+</P>
+<P>
+<b>int pcre_pattern_to_host_byte_order(pcre *<i>code</i>,</b>
+<b>pcre_extra *<i>extra</i>, const unsigned char *<i>tables</i>);</b>
</P>
-<br><a name="SEC3" href="#TOC1">PCRE NATIVE API INDIRECTED FUNCTIONS</a><br>
+<br><a name="SEC4" href="#TOC1">PCRE NATIVE API INDIRECTED FUNCTIONS</a><br>
<P>
<b>void *(*pcre_malloc)(size_t);</b>
</P>
@@ -158,25 +160,51 @@ man page, in case the conversion went wrong.
<P>
<b>int (*pcre_callout)(pcre_callout_block *);</b>
</P>
-<br><a name="SEC4" href="#TOC1">PCRE API OVERVIEW</a><br>
+<br><a name="SEC5" href="#TOC1">PCRE 8-BIT AND 16-BIT LIBRARIES</a><br>
+<P>
+From release 8.30, PCRE can be compiled as a library for handling 16-bit
+character strings as well as, or instead of, the original library that handles
+8-bit character strings. To avoid too much complication, this document
+describes the 8-bit versions of the functions, with only occasional references
+to the 16-bit library.
+</P>
+<P>
+The 16-bit functions operate in the same way as their 8-bit counterparts; they
+just use different data types for their arguments and results, and their names
+start with <b>pcre16_</b> instead of <b>pcre_</b>. For every option that has UTF8
+in its name (for example, PCRE_UTF8), there is a corresponding 16-bit name with
+UTF8 replaced by UTF16. This facility is in fact just cosmetic; the 16-bit
+option names define the same bit values.
+</P>
+<P>
+References to bytes and UTF-8 in this document should be read as references to
+16-bit data quantities and UTF-16 when using the 16-bit library, unless
+specified otherwise. More details of the specific differences for the 16-bit
+library are given in the
+<a href="pcre16.html"><b>pcre16</b></a>
+page.
+</P>
+<br><a name="SEC6" href="#TOC1">PCRE API OVERVIEW</a><br>
<P>
PCRE has its own native API, which is described in this document. There are
-also some wrapper functions that correspond to the POSIX regular expression
-API, but they do not give access to all the functionality. They are described
-in the
+also some wrapper functions (for the 8-bit library only) that correspond to the
+POSIX regular expression API, but they do not give access to all the
+functionality. They are described in the
<a href="pcreposix.html"><b>pcreposix</b></a>
documentation. Both of these APIs define a set of C function calls. A C++
-wrapper is also distributed with PCRE. It is documented in the
+wrapper (again for the 8-bit library only) is also distributed with PCRE. It is
+documented in the
<a href="pcrecpp.html"><b>pcrecpp</b></a>
page.
</P>
<P>
The native API C function prototypes are defined in the header file
-<b>pcre.h</b>, and on Unix systems the library itself is called <b>libpcre</b>.
-It can normally be accessed by adding <b>-lpcre</b> to the command for linking
-an application that uses PCRE. The header file defines the macros PCRE_MAJOR
-and PCRE_MINOR to contain the major and minor release numbers for the library.
-Applications can use these to include support for different releases of PCRE.
+<b>pcre.h</b>, and on Unix-like systems the (8-bit) library itself is called
+<b>libpcre</b>. It can normally be accessed by adding <b>-lpcre</b> to the
+command for linking an application that uses PCRE. The header file defines the
+macros PCRE_MAJOR and PCRE_MINOR to contain the major and minor release numbers
+for the library. Applications can use these to include support for different
+releases of PCRE.
</P>
<P>
In a Windows environment, if you want to statically link an application program
@@ -244,10 +272,8 @@ internal tables that are generated when PCRE is built are used.
</P>
<P>
The function <b>pcre_fullinfo()</b> is used to find out information about a
-compiled pattern; <b>pcre_info()</b> is an obsolete version that returns only
-some of the available information, but is retained for backwards compatibility.
-The function <b>pcre_version()</b> returns a pointer to a string containing the
-version of PCRE and its date of release.
+compiled pattern. The function <b>pcre_version()</b> returns a pointer to a
+string containing the version of PCRE and its date of release.
</P>
<P>
The function <b>pcre_refcount()</b> maintains a reference count in a data block
@@ -284,7 +310,7 @@ points during a matching operation. Details are given in the
<a href="pcrecallout.html"><b>pcrecallout</b></a>
documentation.
<a name="newlines"></a></P>
-<br><a name="SEC5" href="#TOC1">NEWLINES</a><br>
+<br><a name="SEC7" href="#TOC1">NEWLINES</a><br>
<P>
PCRE supports five different conventions for indicating line breaks in
strings: a single CR (carriage return) character, a single LF (linefeed)
@@ -323,7 +349,7 @@ The choice of newline convention does not affect the interpretation of
the \n or \r escape sequences, nor does it affect what \R matches, which is
controlled in a similar way, but by separate options.
</P>
-<br><a name="SEC6" href="#TOC1">MULTITHREADING</a><br>
+<br><a name="SEC8" href="#TOC1">MULTITHREADING</a><br>
<P>
The PCRE functions can be used in multi-threading applications, with the
proviso that the memory management functions pointed to by <b>pcre_malloc</b>,
@@ -340,17 +366,18 @@ memory stack areas for each thread. See the
<a href="pcrejit.html"><b>pcrejit</b></a>
documentation for more details.
</P>
-<br><a name="SEC7" href="#TOC1">SAVING PRECOMPILED PATTERNS FOR LATER USE</a><br>
+<br><a name="SEC9" href="#TOC1">SAVING PRECOMPILED PATTERNS FOR LATER USE</a><br>
<P>
The compiled form of a regular expression can be saved and re-used at a later
time, possibly by a different program, and even on a host other than the one on
which it was compiled. Details are given in the
<a href="pcreprecompile.html"><b>pcreprecompile</b></a>
-documentation. However, compiling a regular expression with one version of PCRE
-for use with a different version is not guaranteed to work and may cause
-crashes.
+documentation, which includes a description of the
+<b>pcre_pattern_to_host_byte_order()</b> function. However, compiling a regular
+expression with one version of PCRE for use with a different version is not
+guaranteed to work and may cause crashes.
</P>
-<br><a name="SEC8" href="#TOC1">CHECKING BUILD-TIME OPTIONS</a><br>
+<br><a name="SEC10" href="#TOC1">CHECKING BUILD-TIME OPTIONS</a><br>
<P>
<b>int pcre_config(int <i>what</i>, void *<i>where</i>);</b>
</P>
@@ -363,12 +390,22 @@ documentation has more details about these optional features.
<P>
The first argument for <b>pcre_config()</b> is an integer, specifying which
information is required; the second argument is a pointer to a variable into
-which the information is placed. The following information is available:
+which the information is placed. The returned value is zero on success, or the
+negative error code PCRE_ERROR_BADOPTION if the value in the first argument is
+not recognized. The following information is available:
<pre>
PCRE_CONFIG_UTF8
</pre>
The output is an integer that is set to one if UTF-8 support is available;
-otherwise it is set to zero.
+otherwise it is set to zero. If this option is given to the 16-bit version of
+this function, <b>pcre16_config()</b>, the result is PCRE_ERROR_BADOPTION.
+<pre>
+ PCRE_CONFIG_UTF16
+</pre>
+The output is an integer that is set to one if UTF-16 support is available;
+otherwise it is set to zero. This value should normally be given to the 16-bit
+version of this function, <b>pcre16_config()</b>. If it is given to the 8-bit
+version of this function, the result is PCRE_ERROR_BADOPTION.
<pre>
PCRE_CONFIG_UNICODE_PROPERTIES
</pre>
@@ -399,10 +436,12 @@ or CRLF. The default can be overridden when a pattern is compiled or matched.
PCRE_CONFIG_LINK_SIZE
</pre>
The output is an integer that contains the number of bytes used for internal
-linkage in compiled regular expressions. The value is 2, 3, or 4. Larger values
-allow larger regular expressions to be compiled, at the expense of slower
-matching. The default value of 2 is sufficient for all but the most massive
-patterns, since it allows the compiled pattern to be up to 64K in size.
+linkage in compiled regular expressions. For the 8-bit library, the value can
+be 2, 3, or 4. For the 16-bit library, the value is either 2 or 4 and is still
+a number of bytes. The default value of 2 is sufficient for all but the most
+massive patterns, since it allows the compiled pattern to be up to 64K in size.
+Larger values allow larger regular expressions to be compiled, at the expense
+of slower matching.
<pre>
PCRE_CONFIG_POSIX_MALLOC_THRESHOLD
</pre>
@@ -434,7 +473,7 @@ of recursive function calls. In this case, <b>pcre_stack_malloc</b> and
<b>pcre_stack_free</b> are called to manage memory blocks on the heap, thus
avoiding the use of the stack.
</P>
-<br><a name="SEC9" href="#TOC1">COMPILING A PATTERN</a><br>
+<br><a name="SEC11" href="#TOC1">COMPILING A PATTERN</a><br>
<P>
<b>pcre *pcre_compile(const char *<i>pattern</i>, int <i>options</i>,</b>
<b>const char **<i>errptr</i>, int *<i>erroffset</i>,</b>
@@ -489,13 +528,13 @@ not try to free it. Normally, the offset from the start of the pattern to the
byte that was being processed when the error was discovered is placed in the
variable pointed to by <i>erroffset</i>, which must not be NULL (if it is, an
immediate error is given). However, for an invalid UTF-8 string, the offset is
-that of the first byte of the failing character. Also, some errors are not
-detected until checks are carried out when the whole pattern has been scanned;
-in these cases the offset passed back is the length of the pattern.
+that of the first byte of the failing character.
</P>
<P>
-Note that the offset is in bytes, not characters, even in UTF-8 mode. It may
-sometimes point into the middle of a UTF-8 character.
+Some errors are not detected until the whole pattern has been scanned; in these
+cases, the offset passed back is the length of the pattern. Note that the
+offset is in bytes, not characters, even in UTF-8 mode. It may sometimes point
+into the middle of a UTF-8 character.
</P>
<P>
If <b>pcre_compile2()</b> is used instead of <b>pcre_compile()</b>, and the
@@ -699,8 +738,8 @@ preceding sequences should be recognized. Setting PCRE_NEWLINE_ANY specifies
that any Unicode newline sequence should be recognized. The Unicode newline
sequences are the three just mentioned, plus the single characters VT (vertical
tab, U+000B), FF (formfeed, U+000C), NEL (next line, U+0085), LS (line
-separator, U+2028), and PS (paragraph separator, U+2029). The last two are
-recognized only in UTF-8 mode.
+separator, U+2028), and PS (paragraph separator, U+2029). For the 8-bit
+library, the last two are recognized only in UTF-8 mode.
</P>
<P>
The newline setting in the options word uses three bits that are treated
@@ -760,34 +799,35 @@ with Perl. It can also be set by a (?U) option setting within the pattern.
PCRE_UTF8
</pre>
This option causes PCRE to regard both the pattern and the subject as strings
-of UTF-8 characters instead of single-byte character strings. However, it is
-available only when PCRE is built to include UTF-8 support. If not, the use
-of this option provokes an error. Details of how this option changes the
-behaviour of PCRE are given in the
+of UTF-8 characters instead of single-byte strings. However, it is available
+only when PCRE is built to include UTF support. If not, the use of this option
+provokes an error. Details of how this option changes the behaviour of PCRE are
+given in the
<a href="pcreunicode.html"><b>pcreunicode</b></a>
page.
<pre>
PCRE_NO_UTF8_CHECK
</pre>
-When PCRE_UTF8 is set, the validity of the pattern as a UTF-8 string is
-automatically checked. There is a discussion about the
-<a href="pcre.html#utf8strings">validity of UTF-8 strings</a>
-in the main
-<a href="pcre.html"><b>pcre</b></a>
-page. If an invalid UTF-8 sequence of bytes is found, <b>pcre_compile()</b>
-returns an error. If you already know that your pattern is valid, and you want
-to skip this check for performance reasons, you can set the PCRE_NO_UTF8_CHECK
-option. When it is set, the effect of passing an invalid UTF-8 string as a
-pattern is undefined. It may cause your program to crash. Note that this option
-can also be passed to <b>pcre_exec()</b> and <b>pcre_dfa_exec()</b>, to suppress
-the UTF-8 validity checking of subject strings.
-</P>
-<br><a name="SEC10" href="#TOC1">COMPILATION ERROR CODES</a><br>
+When PCRE_UTF8 is set, the validity of the pattern as a UTF-8
+string is automatically checked. There is a discussion about the
+<a href="pcreunicode.html#utf8strings">validity of UTF-8 strings</a>
+in the
+<a href="pcreunicode.html"><b>pcreunicode</b></a>
+page. If an invalid UTF-8 sequence is found, <b>pcre_compile()</b> returns an
+error. If you already know that your pattern is valid, and you want to skip
+this check for performance reasons, you can set the PCRE_NO_UTF8_CHECK option.
+When it is set, the effect of passing an invalid UTF-8 string as a pattern is
+undefined. It may cause your program to crash. Note that this option can also
+be passed to <b>pcre_exec()</b> and <b>pcre_dfa_exec()</b>, to suppress the
+validity checking of subject strings.
+</P>
+<br><a name="SEC12" href="#TOC1">COMPILATION ERROR CODES</a><br>
<P>
The following table lists the error codes than may be returned by
<b>pcre_compile2()</b>, along with the error messages that may be returned by
-both compiling functions. As PCRE has developed, some error codes have fallen
-out of use. To avoid confusion, they have not been re-used.
+both compiling functions. Note that error messages are always 8-bit ASCII
+strings, even in 16-bit mode. As PCRE has developed, some error codes have
+fallen out of use. To avoid confusion, they have not been re-used.
<pre>
0 no error
1 \ at end of pattern
@@ -821,7 +861,7 @@ out of use. To avoid confusion, they have not been re-used.
29 (?R or (?[+-]digits must be followed by )
30 unknown POSIX class name
31 POSIX collating elements are not supported
- 32 this version of PCRE is not compiled with PCRE_UTF8 support
+ 32 this version of PCRE is compiled without UTF support
33 [this code is not in use]
34 character value in \x{...} sequence is too large
35 invalid condition (?(0)
@@ -833,14 +873,14 @@ out of use. To avoid confusion, they have not been re-used.
41 unrecognized character after (?P
42 syntax error in subpattern name (missing terminator)
43 two named subpatterns have the same name
- 44 invalid UTF-8 string
+ 44 invalid UTF-8 string (specifically UTF-8)
45 support for \P, \p, and \X has not been compiled
46 malformed \P or \p sequence
47 unknown property name after \P or \p
48 subpattern name is too long (maximum 32 characters)
49 too many named subpatterns (maximum 10000)
50 [this code is not in use]
- 51 octal value is greater than \377 (not in UTF-8 mode)
+ 51 octal value is greater than \377 in 8-bit non-UTF-8 mode
52 internal error: overran compiling workspace
53 internal error: previously-checked referenced subpattern
not found
@@ -859,14 +899,20 @@ out of use. To avoid confusion, they have not been re-used.
65 different names for subpatterns of the same number are
not allowed
66 (*MARK) must have an argument
- 67 this version of PCRE is not compiled with PCRE_UCP support
+ 67 this version of PCRE is not compiled with Unicode property
+ support
68 \c must be followed by an ASCII character
69 \k is not followed by a braced, angle-bracketed, or quoted name
+ 70 internal error: unknown opcode in find_fixedlength()
+ 71 \N is not supported in a class
+ 72 too many forward references
+ 73 disallowed Unicode code point (&#62;= 0xd800 && &#60;= 0xdfff)
+ 74 invalid UTF-16 string (specifically UTF-16)
</pre>
The numbers 32 and 10000 in errors 48 and 49 are defaults; different values may
be used if the limits were changed when PCRE was built.
<a name="studyingapattern"></a></P>
-<br><a name="SEC11" href="#TOC1">STUDYING A PATTERN</a><br>
+<br><a name="SEC13" href="#TOC1">STUDYING A PATTERN</a><br>
<P>
<b>pcre_extra *pcre_study(const pcre *<i>code</i>, int <i>options</i></b>
<b>const char **<i>errptr</i>);</b>
@@ -958,7 +1004,7 @@ in a calling program via the <b>pcre_fullinfo()</b> function.
Studying a pattern is also useful for non-anchored patterns that do not have a
single fixed starting character. A bitmap of possible starting bytes is
created. This speeds up finding a position in the subject at which to start
-matching.
+matching. (In 16-bit mode, the bitmap is used for 16-bit values less than 256.)
</P>
<P>
These two optimizations apply to both <b>pcre_exec()</b> and
@@ -972,18 +1018,19 @@ to make use of these facilities in cases where matching fails. See the
discussion of PCRE_NO_START_OPTIMIZE
<a href="#execoptions">below.</a>
<a name="localesupport"></a></P>
-<br><a name="SEC12" href="#TOC1">LOCALE SUPPORT</a><br>
+<br><a name="SEC14" href="#TOC1">LOCALE SUPPORT</a><br>
<P>
PCRE handles caseless matching, and determines whether characters are letters,
digits, or whatever, by reference to a set of tables, indexed by character
-value. When running in UTF-8 mode, this applies only to characters with codes
-less than 128. By default, higher-valued codes never match escapes such as \w
-or \d, but they can be tested with \p if PCRE is built with Unicode character
-property support. Alternatively, the PCRE_UCP option can be set at compile
-time; this causes \w and friends to use Unicode property support instead of
-built-in tables. The use of locales with Unicode is discouraged. If you are
-handling characters with codes greater than 128, you should either use UTF-8
-and Unicode, or use locales, but not try to mix the two.
+value. When running in UTF-8 mode, this applies only to characters
+with codes less than 128. By default, higher-valued codes never match escapes
+such as \w or \d, but they can be tested with \p if PCRE is built with
+Unicode character property support. Alternatively, the PCRE_UCP option can be
+set at compile time; this causes \w and friends to use Unicode property
+support instead of built-in tables. The use of locales with Unicode is
+discouraged. If you are handling characters with codes greater than 128, you
+should either use UTF-8 and Unicode, or use locales, but not try to mix the
+two.
</P>
<P>
PCRE contains an internal set of tables that are used when the final argument
@@ -1033,15 +1080,15 @@ this facility could be used to match a pattern in a different locale from the
one in which it was compiled. Passing table pointers at run time is discussed
below in the section on matching a pattern.
<a name="infoaboutpattern"></a></P>
-<br><a name="SEC13" href="#TOC1">INFORMATION ABOUT A PATTERN</a><br>
+<br><a name="SEC15" href="#TOC1">INFORMATION ABOUT A PATTERN</a><br>
<P>
<b>int pcre_fullinfo(const pcre *<i>code</i>, const pcre_extra *<i>extra</i>,</b>
<b>int <i>what</i>, void *<i>where</i>);</b>
</P>
<P>
The <b>pcre_fullinfo()</b> function returns information about a compiled
-pattern. It replaces the obsolete <b>pcre_info()</b> function, which is
-nevertheless retained for backwards compability (and is documented below).
+pattern. It replaces the <b>pcre_info()</b> function, which was removed from the
+library at version 8.30, after more than 10 years of obsolescence.
</P>
<P>
The first argument for <b>pcre_fullinfo()</b> is a pointer to the compiled
@@ -1051,14 +1098,18 @@ information is required, and the fourth argument is a pointer to a variable
to receive the data. The yield of the function is zero for success, or one of
the following negative numbers:
<pre>
- PCRE_ERROR_NULL the argument <i>code</i> was NULL
- the argument <i>where</i> was NULL
- PCRE_ERROR_BADMAGIC the "magic number" was not found
- PCRE_ERROR_BADOPTION the value of <i>what</i> was invalid
+ PCRE_ERROR_NULL the argument <i>code</i> was NULL
+ the argument <i>where</i> was NULL
+ PCRE_ERROR_BADMAGIC the "magic number" was not found
+ PCRE_ERROR_BADENDIANNESS the pattern was compiled with different
+ endianness
+ PCRE_ERROR_BADOPTION the value of <i>what</i> was invalid
</pre>
The "magic number" is placed at the start of each compiled pattern as an simple
-check against passing an arbitrary memory pointer. Here is a typical call of
-<b>pcre_fullinfo()</b>, to obtain the length of the compiled pattern:
+check against passing an arbitrary memory pointer. The endianness error can
+occur if a compiled pattern is saved and reloaded on a different host. Here is
+a typical call of <b>pcre_fullinfo()</b>, to obtain the length of the compiled
+pattern:
<pre>
int rc;
size_t length;
@@ -1092,14 +1143,19 @@ a NULL table pointer.
<pre>
PCRE_INFO_FIRSTBYTE
</pre>
-Return information about the first byte of any matched string, for a
-non-anchored pattern. The fourth argument should point to an <b>int</b>
-variable. (This option used to be called PCRE_INFO_FIRSTCHAR; the old name is
-still recognized for backwards compatibility.)
+Return information about the first data unit of any matched string, for a
+non-anchored pattern. (The name of this option refers to the 8-bit library,
+where data units are bytes.) The fourth argument should point to an <b>int</b>
+variable.
+</P>
+<P>
+If there is a fixed first value, for example, the letter "c" from a pattern
+such as (cat|cow|coyote), its value is returned. In the 8-bit library, the
+value is always less than 256; in the 16-bit library the value can be up to
+0xffff.
</P>
<P>
-If there is a fixed first byte, for example, from a pattern such as
-(cat|cow|coyote), its value is returned. Otherwise, if either
+If there is no fixed first value, and if either
<br>
<br>
(a) the pattern was compiled with the PCRE_MULTILINE option, and every branch
@@ -1117,7 +1173,7 @@ returned. For anchored patterns, -2 is returned.
PCRE_INFO_FIRSTTABLE
</pre>
If the pattern was studied, and this resulted in the construction of a 256-bit
-table indicating a fixed set of bytes for the first byte in any matching
+table indicating a fixed set of values for the first data unit in any matching
string, a pointer to the table is returned. Otherwise NULL is returned. The
fourth argument should point to an <b>unsigned char *</b> variable.
<pre>
@@ -1152,11 +1208,11 @@ argument should point to a <b>size_t</b> variable.
<pre>
PCRE_INFO_LASTLITERAL
</pre>
-Return the value of the rightmost literal byte that must exist in any matched
-string, other than at its start, if such a byte has been recorded. The fourth
-argument should point to an <b>int</b> variable. If there is no such byte, -1 is
-returned. For anchored patterns, a last literal byte is recorded only if it
-follows something of variable length. For example, for the pattern
+Return the value of the rightmost literal data unit that must exist in any
+matched string, other than at its start, if such a value has been recorded. The
+fourth argument should point to an <b>int</b> variable. If there is no such
+value, -1 is returned. For anchored patterns, a last literal value is recorded
+only if it follows something of variable length. For example, for the pattern
/^a\d+z\d+/ the returned value is "z", but for /^a\dz\d/ the returned value
is -1.
<pre>
@@ -1164,8 +1220,8 @@ is -1.
</pre>
If the pattern was studied and a minimum length for matching subject strings
was computed, its value is returned. Otherwise the returned value is -1. The
-value is a number of characters, not bytes (this may be relevant in UTF-8
-mode). The fourth argument should point to an <b>int</b> variable. A
+value is a number of characters, which in UTF-8 mode may be different from the
+number of bytes. The fourth argument should point to an <b>int</b> variable. A
non-negative value is a lower bound to the length of any matching string. There
may not be any strings of that length that do actually match, but every string
that does match is at least that long.
@@ -1189,9 +1245,11 @@ The map consists of a number of fixed-size entries. PCRE_INFO_NAMECOUNT gives
the number of entries, and PCRE_INFO_NAMEENTRYSIZE gives the size of each
entry; both of these return an <b>int</b> value. The entry size depends on the
length of the longest name. PCRE_INFO_NAMETABLE returns a pointer to the first
-entry of the table (a pointer to <b>char</b>). The first two bytes of each entry
-are the number of the capturing parenthesis, most significant byte first. The
-rest of the entry is the corresponding name, zero terminated.
+entry of the table. This is a pointer to <b>char</b> in the 8-bit library, where
+the first two bytes of each entry are the number of the capturing parenthesis,
+most significant byte first. In the 16-bit library, the pointer points to
+16-bit data units, the first of which contains the parenthesis number. The rest
+of the entry is the corresponding name, zero terminated.
</P>
<P>
The names are in alphabetical order. Duplicate names may appear if (?| is used
@@ -1207,8 +1265,8 @@ necessarily the case because later subpatterns may have lower numbers.
</P>
<P>
As a simple example of the name/number table, consider the following pattern
-(assume PCRE_EXTENDED is set, so white space - including newlines - is
-ignored):
+after compilation by the 8-bit library (assume PCRE_EXTENDED is set, so white
+space - including newlines - is ignored):
<pre>
(?&#60;date&#62; (?&#60;year&#62;(\d\d)?\d\d) - (?&#60;month&#62;\d\d) - (?&#60;day&#62;\d\d) )
</pre>
@@ -1258,52 +1316,29 @@ For such patterns, the PCRE_ANCHORED bit is set in the options returned by
<pre>
PCRE_INFO_SIZE
</pre>
-Return the size of the compiled pattern. The fourth argument should point to a
-<b>size_t</b> variable. This value does not include the size of the <b>pcre</b>
-structure that is returned by <b>pcre_compile()</b>. The value that is passed as
-the argument to <b>pcre_malloc()</b> when <b>pcre_compile()</b> is getting memory
-in which to place the compiled data is the value returned by this option plus
-the size of the <b>pcre</b> structure. Studying a compiled pattern, with or
-without JIT, does not alter the value returned by this option.
+Return the size of the compiled pattern in bytes (for both libraries). The
+fourth argument should point to a <b>size_t</b> variable. This value does not
+include the size of the <b>pcre</b> structure that is returned by
+<b>pcre_compile()</b>. The value that is passed as the argument to
+<b>pcre_malloc()</b> when <b>pcre_compile()</b> is getting memory in which to
+place the compiled data is the value returned by this option plus the size of
+the <b>pcre</b> structure. Studying a compiled pattern, with or without JIT,
+does not alter the value returned by this option.
<pre>
PCRE_INFO_STUDYSIZE
</pre>
-Return the size of the data block pointed to by the <i>study_data</i> field in a
-<b>pcre_extra</b> block. If <b>pcre_extra</b> is NULL, or there is no study data,
-zero is returned. The fourth argument should point to a <b>size_t</b> variable.
-The <i>study_data</i> field is set by <b>pcre_study()</b> to record information
-that will speed up matching (see the section entitled
+Return the size in bytes of the data block pointed to by the <i>study_data</i>
+field in a <b>pcre_extra</b> block. If <b>pcre_extra</b> is NULL, or there is no
+study data, zero is returned. The fourth argument should point to a
+<b>size_t</b> variable. The <i>study_data</i> field is set by <b>pcre_study()</b>
+to record information that will speed up matching (see the section entitled
<a href="#studyingapattern">"Studying a pattern"</a>
above). The format of the <i>study_data</i> block is private, but its length
is made available via this option so that it can be saved and restored (see the
<a href="pcreprecompile.html"><b>pcreprecompile</b></a>
documentation for details).
</P>
-<br><a name="SEC14" href="#TOC1">OBSOLETE INFO FUNCTION</a><br>
-<P>
-<b>int pcre_info(const pcre *<i>code</i>, int *<i>optptr</i>, int</b>
-<b>*<i>firstcharptr</i>);</b>
-</P>
-<P>
-The <b>pcre_info()</b> function is now obsolete because its interface is too
-restrictive to return all the available data about a compiled pattern. New
-programs should use <b>pcre_fullinfo()</b> instead. The yield of
-<b>pcre_info()</b> is the number of capturing subpatterns, or one of the
-following negative numbers:
-<pre>
- PCRE_ERROR_NULL the argument <i>code</i> was NULL
- PCRE_ERROR_BADMAGIC the "magic number" was not found
-</pre>
-If the <i>optptr</i> argument is not NULL, a copy of the options with which the
-pattern was compiled is placed in the integer it points to (see
-PCRE_INFO_OPTIONS above).
-</P>
-<P>
-If the pattern is not anchored and the <i>firstcharptr</i> argument is not NULL,
-it is used to pass back information about the first character of any matched
-string (see PCRE_INFO_FIRSTBYTE above).
-</P>
-<br><a name="SEC15" href="#TOC1">REFERENCE COUNTS</a><br>
+<br><a name="SEC16" href="#TOC1">REFERENCE COUNTS</a><br>
<P>
<b>int pcre_refcount(pcre *<i>code</i>, int <i>adjust</i>);</b>
</P>
@@ -1327,7 +1362,7 @@ Except when it is zero, the reference count is not correctly preserved if a
pattern is compiled on one host and then transferred to a host whose byte-order
is different. (This seems a highly unlikely scenario.)
</P>
-<br><a name="SEC16" href="#TOC1">MATCHING A PATTERN: THE TRADITIONAL FUNCTION</a><br>
+<br><a name="SEC17" href="#TOC1">MATCHING A PATTERN: THE TRADITIONAL FUNCTION</a><br>
<P>
<b>int pcre_exec(const pcre *<i>code</i>, const pcre_extra *<i>extra</i>,</b>
<b>const char *<i>subject</i>, int <i>length</i>, int <i>startoffset</i>,</b>
@@ -1392,6 +1427,10 @@ fields (not necessarily in this order):
const unsigned char *<i>tables</i>;
unsigned char **<i>mark</i>;
</pre>
+In the 16-bit version of this structure, the <i>mark</i> field has type
+"PCRE_UCHAR16 **".
+</P>
+<P>
The <i>flags</i> field is a bitmap that specifies which of the other fields
are set. The flag bits are:
<pre>
@@ -1482,13 +1521,13 @@ documentation for a discussion of saving compiled patterns for later use.
</P>
<P>
If PCRE_EXTRA_MARK is set in the <i>flags</i> field, the <i>mark</i> field must
-be set to point to a <b>char *</b> variable. If the pattern contains any
+be set to point to a suitable variable. If the pattern contains any
backtracking control verbs such as (*MARK:NAME), and the execution ends up with
a name to pass back, a pointer to the name string (zero terminated) is placed
in the variable pointed to by the <i>mark</i> field. The names are within the
compiled pattern; if you wish to retain such a name you must copy it before
freeing the memory of a compiled pattern. If there is no name to pass back, the
-variable pointed to by the <i>mark</i> field set to NULL. For details of the
+variable pointed to by the <i>mark</i> field is set to NULL. For details of the
backtracking control verbs, see the section entitled
<a href="pcrepattern#backtrackcontrol">"Backtracking control"</a>
in the
@@ -1671,15 +1710,13 @@ string is automatically checked when <b>pcre_exec()</b> is subsequently called.
The value of <i>startoffset</i> is also checked to ensure that it points to the
start of a UTF-8 character. There is a discussion about the validity of UTF-8
strings in the
-<a href="pcre.html#utf8strings">section on UTF-8 support</a>
-in the main
-<a href="pcre.html"><b>pcre</b></a>
-page. If an invalid UTF-8 sequence of bytes is found, <b>pcre_exec()</b> returns
-the error PCRE_ERROR_BADUTF8 or, if PCRE_PARTIAL_HARD is set and the problem is
-a truncated UTF-8 character at the end of the subject, PCRE_ERROR_SHORTUTF8. In
-both cases, information about the precise nature of the error may also be
-returned (see the descriptions of these errors in the section entitled \fIError
-return values from\fP <b>pcre_exec()</b>
+<a href="pcreunicode.html"><b>pcreunicode</b></a>
+page. If an invalid sequence of bytes is found, <b>pcre_exec()</b> returns the
+error PCRE_ERROR_BADUTF8 or, if PCRE_PARTIAL_HARD is set and the problem is a
+truncated character at the end of the subject, PCRE_ERROR_SHORTUTF8. In both
+cases, information about the precise nature of the error may also be returned
+(see the descriptions of these errors in the section entitled \fIError return
+values from\fP <b>pcre_exec()</b>
<a href="#errorlist">below).</a>
If <i>startoffset</i> contains a value that does not point to the start of a
UTF-8 character (or to the end of the subject), PCRE_ERROR_BADUTF8_OFFSET is
@@ -1691,9 +1728,9 @@ checks for performance reasons, you can set the PCRE_NO_UTF8_CHECK option when
calling <b>pcre_exec()</b>. You might want to do this for the second and
subsequent calls to <b>pcre_exec()</b> if you are making repeated calls to find
all the matches in a single subject string. However, you should be sure that
-the value of <i>startoffset</i> points to the start of a UTF-8 character (or the
-end of the subject). When PCRE_NO_UTF8_CHECK is set, the effect of passing an
-invalid UTF-8 string as a subject or an invalid value of <i>startoffset</i> is
+the value of <i>startoffset</i> points to the start of a character (or the end
+of the subject). When PCRE_NO_UTF8_CHECK is set, the effect of passing an
+invalid string as a subject or an invalid value of <i>startoffset</i> is
undefined. Your program may crash.
<pre>
PCRE_PARTIAL_HARD
@@ -1728,7 +1765,7 @@ The string to be matched by <b>pcre_exec()</b>
</b><br>
<P>
The subject string is passed to <b>pcre_exec()</b> as a pointer in
-<i>subject</i>, a length (in bytes) in <i>length</i>, and a starting byte offset
+<i>subject</i>, a length in bytes in <i>length</i>, and a starting byte offset
in <i>startoffset</i>. If this is negative or greater than the length of the
subject, <b>pcre_exec()</b> returns PCRE_ERROR_BADOFFSET. When the starting
offset is zero, the search for a match starts at the beginning of the subject,
@@ -2027,6 +2064,18 @@ PCRE_STUDY_JIT_COMPILE option is being matched, but the memory available for
the just-in-time processing stack is not large enough. See the
<a href="pcrejit.html"><b>pcrejit</b></a>
documentation for more details.
+<pre>
+ PCRE_ERROR_BADMODE (-28)
+</pre>
+This error is given if a pattern that was compiled by the 8-bit library is
+passed to a 16-bit library function, or vice versa.
+<pre>
+ PCRE_ERROR_BADENDIANNESS (-29)
+</pre>
+This error is given if a pattern that was compiled and saved is reloaded on a
+host with different endianness. The utility function
+<b>pcre_pattern_to_host_byte_order()</b> can be used to convert such a pattern
+so that it runs on the new host.
</P>
<P>
Error numbers -16 to -20 and -22 are not used by <b>pcre_exec()</b>.
@@ -2035,6 +2084,12 @@ Error numbers -16 to -20 and -22 are not used by <b>pcre_exec()</b>.
Reason codes for invalid UTF-8 strings
</b><br>
<P>
+This section applies only to the 8-bit library. The corresponding information
+for the 16-bit library is given in the
+<a href="pcre16.html"><b>pcre16</b></a>
+page.
+</P>
+<P>
When <b>pcre_exec()</b> returns either PCRE_ERROR_BADUTF8 or
PCRE_ERROR_SHORTUTF8, and the size of the output vector (<i>ovecsize</i>) is at
least 2, the offset of the start of the invalid UTF-8 character is placed in
@@ -2104,7 +2159,7 @@ character.
The first byte of a character has the value 0xfe or 0xff. These values can
never occur in a valid UTF-8 string.
</P>
-<br><a name="SEC17" href="#TOC1">EXTRACTING CAPTURED SUBSTRINGS BY NUMBER</a><br>
+<br><a name="SEC18" href="#TOC1">EXTRACTING CAPTURED SUBSTRINGS BY NUMBER</a><br>
<P>
<b>int pcre_copy_substring(const char *<i>subject</i>, int *<i>ovector</i>,</b>
<b>int <i>stringcount</i>, int <i>stringnumber</i>, char *<i>buffer</i>,</b>
@@ -2199,7 +2254,7 @@ linked via a special interface to another programming language that cannot use
<b>pcre_free</b> directly; it is for these cases that the functions are
provided.
</P>
-<br><a name="SEC18" href="#TOC1">EXTRACTING CAPTURED SUBSTRINGS BY NAME</a><br>
+<br><a name="SEC19" href="#TOC1">EXTRACTING CAPTURED SUBSTRINGS BY NAME</a><br>
<P>
<b>int pcre_get_stringnumber(const pcre *<i>code</i>,</b>
<b>const char *<i>name</i>);</b>
@@ -2263,7 +2318,7 @@ names are not included in the compiled code. The matching process uses only
numbers. For this reason, the use of different names for subpatterns of the
same number causes an error at compile time.
</P>
-<br><a name="SEC19" href="#TOC1">DUPLICATE SUBPATTERN NAMES</a><br>
+<br><a name="SEC20" href="#TOC1">DUPLICATE SUBPATTERN NAMES</a><br>
<P>
<b>int pcre_get_stringtable_entries(const pcre *<i>code</i>,</b>
<b>const char *<i>name</i>, char **<i>first</i>, char **<i>last</i>);</b>
@@ -2301,7 +2356,7 @@ described above in the section entitled <i>Information about a pattern</i>
Given all the relevant entries for the name, you can extract each of their
numbers, and hence the captured data, if any.
</P>
-<br><a name="SEC20" href="#TOC1">FINDING ALL POSSIBLE MATCHES</a><br>
+<br><a name="SEC21" href="#TOC1">FINDING ALL POSSIBLE MATCHES</a><br>
<P>
The traditional matching function uses a similar algorithm to Perl, which stops
when it finds the first match, starting at a given point in the subject. If you
@@ -2320,7 +2375,7 @@ substring. Then return 1, which forces <b>pcre_exec()</b> to backtrack and try
other alternatives. Ultimately, when it runs out of matches, <b>pcre_exec()</b>
will yield PCRE_ERROR_NOMATCH.
<a name="dfamatch"></a></P>
-<br><a name="SEC21" href="#TOC1">MATCHING A PATTERN: THE ALTERNATIVE FUNCTION</a><br>
+<br><a name="SEC22" href="#TOC1">MATCHING A PATTERN: THE ALTERNATIVE FUNCTION</a><br>
<P>
<b>int pcre_dfa_exec(const pcre *<i>code</i>, const pcre_extra *<i>extra</i>,</b>
<b>const char *<i>subject</i>, int <i>length</i>, int <i>startoffset</i>,</b>
@@ -2495,13 +2550,13 @@ recursively, using private vectors for <i>ovector</i> and <i>workspace</i>. This
error is given if the output vector is not large enough. This should be
extremely rare, as a vector of size 1000 is used.
</P>
-<br><a name="SEC22" href="#TOC1">SEE ALSO</a><br>
+<br><a name="SEC23" href="#TOC1">SEE ALSO</a><br>
<P>
-<b>pcrebuild</b>(3), <b>pcrecallout</b>(3), <b>pcrecpp(3)</b>(3),
+<b>pcre16</b>(3), <b>pcrebuild</b>(3), <b>pcrecallout</b>(3), <b>pcrecpp(3)</b>(3),
<b>pcrematching</b>(3), <b>pcrepartial</b>(3), <b>pcreposix</b>(3),
<b>pcreprecompile</b>(3), <b>pcresample</b>(3), <b>pcrestack</b>(3).
</P>
-<br><a name="SEC23" href="#TOC1">AUTHOR</a><br>
+<br><a name="SEC24" href="#TOC1">AUTHOR</a><br>
<P>
Philip Hazel
<br>
@@ -2510,11 +2565,11 @@ University Computing Service
Cambridge CB2 3QH, England.
<br>
</P>
-<br><a name="SEC24" href="#TOC1">REVISION</a><br>
+<br><a name="SEC25" href="#TOC1">REVISION</a><br>
<P>
-Last updated: 02 December 2011
+Last updated: 07 January 2012
<br>
-Copyright &copy; 1997-2011 University of Cambridge.
+Copyright &copy; 1997-2012 University of Cambridge.
<br>
<p>
Return to the <a href="index.html">PCRE index page</a>.
diff --git a/doc/html/pcrebuild.html b/doc/html/pcrebuild.html
index 664812d..cda280a 100644
--- a/doc/html/pcrebuild.html
+++ b/doc/html/pcrebuild.html
@@ -14,25 +14,26 @@ man page, in case the conversion went wrong.
<br>
<ul>
<li><a name="TOC1" href="#SEC1">PCRE BUILD-TIME OPTIONS</a>
-<li><a name="TOC2" href="#SEC2">BUILDING SHARED AND STATIC LIBRARIES</a>
-<li><a name="TOC3" href="#SEC3">C++ SUPPORT</a>
-<li><a name="TOC4" href="#SEC4">UTF-8 SUPPORT</a>
-<li><a name="TOC5" href="#SEC5">UNICODE CHARACTER PROPERTY SUPPORT</a>
-<li><a name="TOC6" href="#SEC6">JUST-IN-TIME COMPILER SUPPORT</a>
-<li><a name="TOC7" href="#SEC7">CODE VALUE OF NEWLINE</a>
-<li><a name="TOC8" href="#SEC8">WHAT \R MATCHES</a>
-<li><a name="TOC9" href="#SEC9">POSIX MALLOC USAGE</a>
-<li><a name="TOC10" href="#SEC10">HANDLING VERY LARGE PATTERNS</a>
-<li><a name="TOC11" href="#SEC11">AVOIDING EXCESSIVE STACK USAGE</a>
-<li><a name="TOC12" href="#SEC12">LIMITING PCRE RESOURCE USAGE</a>
-<li><a name="TOC13" href="#SEC13">CREATING CHARACTER TABLES AT BUILD TIME</a>
-<li><a name="TOC14" href="#SEC14">USING EBCDIC CODE</a>
-<li><a name="TOC15" href="#SEC15">PCREGREP OPTIONS FOR COMPRESSED FILE SUPPORT</a>
-<li><a name="TOC16" href="#SEC16">PCREGREP BUFFER SIZE</a>
-<li><a name="TOC17" href="#SEC17">PCRETEST OPTION FOR LIBREADLINE SUPPORT</a>
-<li><a name="TOC18" href="#SEC18">SEE ALSO</a>
-<li><a name="TOC19" href="#SEC19">AUTHOR</a>
-<li><a name="TOC20" href="#SEC20">REVISION</a>
+<li><a name="TOC2" href="#SEC2">BUILDING 8-BIT and 16-BIT LIBRARIES</a>
+<li><a name="TOC3" href="#SEC3">BUILDING SHARED AND STATIC LIBRARIES</a>
+<li><a name="TOC4" href="#SEC4">C++ SUPPORT</a>
+<li><a name="TOC5" href="#SEC5">UTF-8 and UTF-16 SUPPORT</a>
+<li><a name="TOC6" href="#SEC6">UNICODE CHARACTER PROPERTY SUPPORT</a>
+<li><a name="TOC7" href="#SEC7">JUST-IN-TIME COMPILER SUPPORT</a>
+<li><a name="TOC8" href="#SEC8">CODE VALUE OF NEWLINE</a>
+<li><a name="TOC9" href="#SEC9">WHAT \R MATCHES</a>
+<li><a name="TOC10" href="#SEC10">POSIX MALLOC USAGE</a>
+<li><a name="TOC11" href="#SEC11">HANDLING VERY LARGE PATTERNS</a>
+<li><a name="TOC12" href="#SEC12">AVOIDING EXCESSIVE STACK USAGE</a>
+<li><a name="TOC13" href="#SEC13">LIMITING PCRE RESOURCE USAGE</a>
+<li><a name="TOC14" href="#SEC14">CREATING CHARACTER TABLES AT BUILD TIME</a>
+<li><a name="TOC15" href="#SEC15">USING EBCDIC CODE</a>
+<li><a name="TOC16" href="#SEC16">PCREGREP OPTIONS FOR COMPRESSED FILE SUPPORT</a>
+<li><a name="TOC17" href="#SEC17">PCREGREP BUFFER SIZE</a>
+<li><a name="TOC18" href="#SEC18">PCRETEST OPTION FOR LIBREADLINE SUPPORT</a>
+<li><a name="TOC19" href="#SEC19">SEE ALSO</a>
+<li><a name="TOC20" href="#SEC20">AUTHOR</a>
+<li><a name="TOC21" href="#SEC21">REVISION</a>
</ul>
<br><a name="SEC1" href="#TOC1">PCRE BUILD-TIME OPTIONS</a><br>
<P>
@@ -63,7 +64,26 @@ The following sections include descriptions of options whose names begin with
--enable and --disable always come in pairs, so the complementary option always
exists as well, but as it specifies the default, it is not described.
</P>
-<br><a name="SEC2" href="#TOC1">BUILDING SHARED AND STATIC LIBRARIES</a><br>
+<br><a name="SEC2" href="#TOC1">BUILDING 8-BIT and 16-BIT LIBRARIES</a><br>
+<P>
+By default, a library called <b>libpcre</b> is built, containing functions that
+take string arguments contained in vectors of bytes, either as single-byte
+characters, or interpreted as UTF-8 strings. You can also build a separate
+library, called <b>libpcre16</b>, in which strings are contained in vectors of
+16-bit data units and interpreted either as single-unit characters or UTF-16
+strings, by adding
+<pre>
+ --enable-pcre16
+</pre>
+to the <b>configure</b> command. If you do not want the 8-bit library, add
+<pre>
+ --disable-pcre8
+</pre>
+as well. At least one of the two libraries must be built. Note that the C++ and
+POSIX wrappers are for the 8-bit library only, and that <b>pcregrep</b> is an
+8-bit program. None of these are built if you select only the 16-bit library.
+</P>
+<br><a name="SEC3" href="#TOC1">BUILDING SHARED AND STATIC LIBRARIES</a><br>
<P>
The PCRE building process uses <b>libtool</b> to build both shared and static
Unix libraries by default. You can suppress one of these by adding one of
@@ -73,45 +93,53 @@ Unix libraries by default. You can suppress one of these by adding one of
</pre>
to the <b>configure</b> command, as required.
</P>
-<br><a name="SEC3" href="#TOC1">C++ SUPPORT</a><br>
+<br><a name="SEC4" href="#TOC1">C++ SUPPORT</a><br>
<P>
-By default, the <b>configure</b> script will search for a C++ compiler and C++
-header files. If it finds them, it automatically builds the C++ wrapper library
-for PCRE. You can disable this by adding
+By default, if the 8-bit library is being built, the <b>configure</b> script
+will search for a C++ compiler and C++ header files. If it finds them, it
+automatically builds the C++ wrapper library (which supports only 8-bit
+strings). You can disable this by adding
<pre>
--disable-cpp
</pre>
to the <b>configure</b> command.
</P>
-<br><a name="SEC4" href="#TOC1">UTF-8 SUPPORT</a><br>
+<br><a name="SEC5" href="#TOC1">UTF-8 and UTF-16 SUPPORT</a><br>
<P>
-To build PCRE with support for UTF-8 Unicode character strings, add
+To build PCRE with support for UTF Unicode character strings, add
<pre>
- --enable-utf8
+ --enable-utf
</pre>
-to the <b>configure</b> command. Of itself, this does not make PCRE treat
-strings as UTF-8. As well as compiling PCRE with this option, you also have
-have to set the PCRE_UTF8 option when you call the <b>pcre_compile()</b>
-or <b>pcre_compile2()</b> functions.
+to the <b>configure</b> command. This setting applies to both libraries, adding
+support for UTF-8 to the 8-bit library and support for UTF-16 to the 16-bit
+library. It is not possible to build one library with UTF support and the other
+without in the same configuration. (For backwards compatibility, --enable-utf8
+is a synonym of --enable-utf.)
+</P>
+<P>
+Of itself, this setting does not make PCRE treat strings as UTF-8 or UTF-16. As
+well as compiling PCRE with this option, you also have have to set the
+PCRE_UTF8 or PCRE_UTF16 option when you call one of the pattern compiling
+functions.
</P>
<P>
-If you set --enable-utf8 when compiling in an EBCDIC environment, PCRE expects
+If you set --enable-utf when compiling in an EBCDIC environment, PCRE expects
its input to be either ASCII or UTF-8 (depending on the runtime option). It is
not possible to support both EBCDIC and UTF-8 codes in the same version of the
-library. Consequently, --enable-utf8 and --enable-ebcdic are mutually
+library. Consequently, --enable-utf and --enable-ebcdic are mutually
exclusive.
</P>
-<br><a name="SEC5" href="#TOC1">UNICODE CHARACTER PROPERTY SUPPORT</a><br>
+<br><a name="SEC6" href="#TOC1">UNICODE CHARACTER PROPERTY SUPPORT</a><br>
<P>
-UTF-8 support allows PCRE to process character values greater than 255 in the
-strings that it handles. On its own, however, it does not provide any
+UTF support allows the libraries to process character codepoints up to 0x10ffff
+in the strings that they handle. On its own, however, it does not provide any
facilities for accessing the properties of such characters. If you want to be
able to use the pattern escapes \P, \p, and \X, which refer to Unicode
character properties, you must add
<pre>
--enable-unicode-properties
</pre>
-to the <b>configure</b> command. This implies UTF-8 support, even if you have
+to the <b>configure</b> command. This implies UTF support, even if you have
not explicitly requested it.
</P>
<P>
@@ -121,7 +149,7 @@ supported. Details are given in the
<a href="pcrepattern.html"><b>pcrepattern</b></a>
documentation.
</P>
-<br><a name="SEC6" href="#TOC1">JUST-IN-TIME COMPILER SUPPORT</a><br>
+<br><a name="SEC7" href="#TOC1">JUST-IN-TIME COMPILER SUPPORT</a><br>
<P>
Just-in-time compiler support is included in the build by specifying
<pre>
@@ -138,7 +166,7 @@ pcregrep automatically makes use of it, unless you add
</pre>
to the "configure" command.
</P>
-<br><a name="SEC7" href="#TOC1">CODE VALUE OF NEWLINE</a><br>
+<br><a name="SEC8" href="#TOC1">CODE VALUE OF NEWLINE</a><br>
<P>
By default, PCRE interprets the linefeed (LF) character as indicating the end
of a line. This is the normal newline character on Unix-like systems. You can
@@ -171,7 +199,7 @@ Whatever line ending convention is selected when PCRE is built can be
overridden when the library functions are called. At build time it is
conventional to use the standard for your operating system.
</P>
-<br><a name="SEC8" href="#TOC1">WHAT \R MATCHES</a><br>
+<br><a name="SEC9" href="#TOC1">WHAT \R MATCHES</a><br>
<P>
By default, the sequence \R in a pattern matches any Unicode newline sequence,
whatever has been selected as the line ending sequence. If you specify
@@ -182,9 +210,9 @@ the default is changed so that \R matches only CR, LF, or CRLF. Whatever is
selected when PCRE is built can be overridden when the library functions are
called.
</P>
-<br><a name="SEC9" href="#TOC1">POSIX MALLOC USAGE</a><br>
+<br><a name="SEC10" href="#TOC1">POSIX MALLOC USAGE</a><br>
<P>
-When PCRE is called through the POSIX interface (see the
+When the 8-bit library is called through the POSIX interface (see the
<a href="pcreposix.html"><b>pcreposix</b></a>
documentation), additional working storage is required for holding the pointers
to capturing substrings, because PCRE requires three integers per substring,
@@ -198,23 +226,24 @@ such as
</pre>
to the <b>configure</b> command.
</P>
-<br><a name="SEC10" href="#TOC1">HANDLING VERY LARGE PATTERNS</a><br>
+<br><a name="SEC11" href="#TOC1">HANDLING VERY LARGE PATTERNS</a><br>
<P>
Within a compiled pattern, offset values are used to point from one part to
another (for example, from an opening parenthesis to an alternation
metacharacter). By default, two-byte values are used for these offsets, leading
to a maximum size for a compiled pattern of around 64K. This is sufficient to
handle all but the most gigantic patterns. Nevertheless, some people do want to
-process truyl enormous patterns, so it is possible to compile PCRE to use
+process truly enormous patterns, so it is possible to compile PCRE to use
three-byte or four-byte offsets by adding a setting such as
<pre>
--with-link-size=3
</pre>
-to the <b>configure</b> command. The value given must be 2, 3, or 4. Using
-longer offsets slows down the operation of PCRE because it has to load
-additional bytes when handling them.
+to the <b>configure</b> command. The value given must be 2, 3, or 4. For the
+16-bit library, a value of 3 is rounded up to 4. Using longer offsets slows
+down the operation of PCRE because it has to load additional data when handling
+them.
</P>
-<br><a name="SEC11" href="#TOC1">AVOIDING EXCESSIVE STACK USAGE</a><br>
+<br><a name="SEC12" href="#TOC1">AVOIDING EXCESSIVE STACK USAGE</a><br>
<P>
When matching with the <b>pcre_exec()</b> function, PCRE implements backtracking
by making recursive calls to an internal function called <b>match()</b>. In
@@ -245,7 +274,7 @@ perform better than <b>malloc()</b> and <b>free()</b>. PCRE runs noticeably more
slowly when built in this way. This option affects only the <b>pcre_exec()</b>
function; it is not relevant for <b>pcre_dfa_exec()</b>.
</P>
-<br><a name="SEC12" href="#TOC1">LIMITING PCRE RESOURCE USAGE</a><br>
+<br><a name="SEC13" href="#TOC1">LIMITING PCRE RESOURCE USAGE</a><br>
<P>
Internally, PCRE has a function called <b>match()</b>, which it calls repeatedly
(sometimes recursively) when matching a pattern with the <b>pcre_exec()</b>
@@ -274,7 +303,7 @@ constraints. However, you can set a lower limit by adding, for example,
</pre>
to the <b>configure</b> command. This value can also be overridden at run time.
</P>
-<br><a name="SEC13" href="#TOC1">CREATING CHARACTER TABLES AT BUILD TIME</a><br>
+<br><a name="SEC14" href="#TOC1">CREATING CHARACTER TABLES AT BUILD TIME</a><br>
<P>
PCRE uses fixed tables for processing characters whose code values are less
than 256. By default, PCRE is built with a set of tables that are distributed
@@ -291,7 +320,7 @@ compiling, because <b>dftables</b> is run on the local host. If you need to
create alternative tables when cross compiling, you will have to do so "by
hand".)
</P>
-<br><a name="SEC14" href="#TOC1">USING EBCDIC CODE</a><br>
+<br><a name="SEC15" href="#TOC1">USING EBCDIC CODE</a><br>
<P>
PCRE assumes by default that it will run in an environment where the character
code is ASCII (or Unicode, which is a superset of ASCII). This is the case for
@@ -303,9 +332,9 @@ EBCDIC environment by adding
to the <b>configure</b> command. This setting implies
--enable-rebuild-chartables. You should only use it if you know that you are in
an EBCDIC environment (for example, an IBM mainframe operating system). The
---enable-ebcdic option is incompatible with --enable-utf8.
+--enable-ebcdic option is incompatible with --enable-utf.
</P>
-<br><a name="SEC15" href="#TOC1">PCREGREP OPTIONS FOR COMPRESSED FILE SUPPORT</a><br>
+<br><a name="SEC16" href="#TOC1">PCREGREP OPTIONS FOR COMPRESSED FILE SUPPORT</a><br>
<P>
By default, <b>pcregrep</b> reads all files as plain text. You can build it so
that it recognizes files whose names end in <b>.gz</b> or <b>.bz2</b>, and reads
@@ -318,7 +347,7 @@ to the <b>configure</b> command. These options naturally require that the
relevant libraries are installed on your system. Configuration will fail if
they are not.
</P>
-<br><a name="SEC16" href="#TOC1">PCREGREP BUFFER SIZE</a><br>
+<br><a name="SEC17" href="#TOC1">PCREGREP BUFFER SIZE</a><br>
<P>
<b>pcregrep</b> uses an internal buffer to hold a "window" on the file it is
scanning, in order to be able to output "before" and "after" lines when it
@@ -333,7 +362,7 @@ parameter value by adding, for example,
to the <b>configure</b> command. The caller of \fPpcregrep\fP can, however,
override this value by specifying a run-time option.
</P>
-<br><a name="SEC17" href="#TOC1">PCRETEST OPTION FOR LIBREADLINE SUPPORT</a><br>
+<br><a name="SEC18" href="#TOC1">PCRETEST OPTION FOR LIBREADLINE SUPPORT</a><br>
<P>
If you add
<pre>
@@ -364,11 +393,11 @@ automatically included, you may need to add something like
</pre>
immediately before the <b>configure</b> command.
</P>
-<br><a name="SEC18" href="#TOC1">SEE ALSO</a><br>
+<br><a name="SEC19" href="#TOC1">SEE ALSO</a><br>
<P>
-<b>pcreapi</b>(3), <b>pcre_config</b>(3).
+<b>pcreapi</b>(3), <b>pcre16</b>, <b>pcre_config</b>(3).
</P>
-<br><a name="SEC19" href="#TOC1">AUTHOR</a><br>
+<br><a name="SEC20" href="#TOC1">AUTHOR</a><br>
<P>
Philip Hazel
<br>
@@ -377,11 +406,11 @@ University Computing Service
Cambridge CB2 3QH, England.
<br>
</P>
-<br><a name="SEC20" href="#TOC1">REVISION</a><br>
+<br><a name="SEC21" href="#TOC1">REVISION</a><br>
<P>
-Last updated: 06 September 2011
+Last updated: 07 January 2012
<br>
-Copyright &copy; 1997-2011 University of Cambridge.
+Copyright &copy; 1997-2012 University of Cambridge.
<br>
<p>
Return to the <a href="index.html">PCRE index page</a>.
diff --git a/doc/html/pcrecallout.html b/doc/html/pcrecallout.html
index e891fdf..75bda4b 100644
--- a/doc/html/pcrecallout.html
+++ b/doc/html/pcrecallout.html
@@ -25,11 +25,15 @@ man page, in case the conversion went wrong.
<b>int (*pcre_callout)(pcre_callout_block *);</b>
</P>
<P>
+<b>int (*pcre16_callout)(pcre16_callout_block *);</b>
+</P>
+<P>
PCRE provides a feature called "callout", which is a means of temporarily
passing control to the caller of PCRE in the middle of pattern matching. The
caller of PCRE provides an external function by putting its entry point in the
-global variable <i>pcre_callout</i>. By default, this variable contains NULL,
-which disables all calling out.
+global variable <i>pcre_callout</i> (<i>pcre16_callout</i> for the 16-bit
+library). By default, this variable contains NULL, which disables all calling
+out.
</P>
<P>
Within a regular expression, (?C) indicates the points at which the external
@@ -39,10 +43,9 @@ For example, this pattern has two callout points:
<pre>
(?C1)abc(?C2)def
</pre>
-If the PCRE_AUTO_CALLOUT option bit is set when <b>pcre_compile()</b> or
-<b>pcre_compile2()</b> is called, PCRE automatically inserts callouts, all with
-number 255, before each item in the pattern. For example, if PCRE_AUTO_CALLOUT
-is used with the pattern
+If the PCRE_AUTO_CALLOUT option bit is set when a pattern is compiled, PCRE
+automatically inserts callouts, all with number 255, before each item in the
+pattern. For example, if PCRE_AUTO_CALLOUT is used with the pattern
<pre>
A(\d{2}|--)
</pre>
@@ -86,31 +89,33 @@ been scanned far enough.
</P>
<P>
You can disable these optimizations by passing the PCRE_NO_START_OPTIMIZE
-option to <b>pcre_compile()</b>, <b>pcre_exec()</b>, or <b>pcre_dfa_exec()</b>,
-or by starting the pattern with (*NO_START_OPT). This slows down the matching
-process, but does ensure that callouts such as the example above are obeyed.
+option to the matching function, or by starting the pattern with
+(*NO_START_OPT). This slows down the matching process, but does ensure that
+callouts such as the example above are obeyed.
</P>
<br><a name="SEC3" href="#TOC1">THE CALLOUT INTERFACE</a><br>
<P>
During matching, when PCRE reaches a callout point, the external function
-defined by <i>pcre_callout</i> is called (if it is set). This applies to both
-the <b>pcre_exec()</b> and the <b>pcre_dfa_exec()</b> matching functions. The
-only argument to the callout function is a pointer to a <b>pcre_callout</b>
-block. This structure contains the following fields:
+defined by <i>pcre_callout</i> or <i>pcre16_callout</i> is called (if it is set).
+This applies to both normal and DFA matching. The only argument to the callout
+function is a pointer to a <b>pcre_callout</b> or <b>pcre16_callout</b> block.
+These structures contains the following fields:
<pre>
- int <i>version</i>;
- int <i>callout_number</i>;
- int *<i>offset_vector</i>;
- const char *<i>subject</i>;
- int <i>subject_length</i>;
- int <i>start_match</i>;
- int <i>current_position</i>;
- int <i>capture_top</i>;
- int <i>capture_last</i>;
- void *<i>callout_data</i>;
- int <i>pattern_position</i>;
- int <i>next_item_length</i>;
- const unsigned char *<i>mark</i>;
+ int <i>version</i>;
+ int <i>callout_number</i>;
+ int *<i>offset_vector</i>;
+ const char *<i>subject</i>; (8-bit version)
+ PCRE_SPTR16 <i>subject</i>; (16-bit version)
+ int <i>subject_length</i>;
+ int <i>start_match</i>;
+ int <i>current_position</i>;
+ int <i>capture_top</i>;
+ int <i>capture_last</i>;
+ void *<i>callout_data</i>;
+ int <i>pattern_position</i>;
+ int <i>next_item_length</i>;
+ const unsigned char *<i>mark</i>; (8-bit version)
+ const PCRE_UCHAR16 *<i>mark</i>; (16-bit version)
</pre>
The <i>version</i> field is an integer containing the version number of the
block format. The initial version was 0; the current version is 2. The version
@@ -124,15 +129,15 @@ automatically generated callouts).
</P>
<P>
The <i>offset_vector</i> field is a pointer to the vector of offsets that was
-passed by the caller to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>. When
-<b>pcre_exec()</b> is used, the contents can be inspected in order to extract
+passed by the caller to the matching function. When <b>pcre_exec()</b> or
+<b>pcre16_exec()</b> is used, the contents can be inspected, in order to extract
substrings that have been matched so far, in the same way as for extracting
-substrings after a match has completed. For <b>pcre_dfa_exec()</b> this field is
-not useful.
+substrings after a match has completed. For the DFA matching functions, this
+field is not useful.
</P>
<P>
The <i>subject</i> and <i>subject_length</i> fields contain copies of the values
-that were passed to <b>pcre_exec()</b>.
+that were passed to the matching function.
</P>
<P>
The <i>start_match</i> field normally contains the offset within the subject at
@@ -147,39 +152,38 @@ The <i>current_position</i> field contains the offset within the subject of the
current match pointer.
</P>
<P>
-When the <b>pcre_exec()</b> function is used, the <i>capture_top</i> field
-contains one more than the number of the highest numbered captured substring so
-far. If no substrings have been captured, the value of <i>capture_top</i> is
-one. This is always the case when <b>pcre_dfa_exec()</b> is used, because it
-does not support captured substrings.
+When the <b>pcre_exec()</b> or <b>pcre16_exec()</b> is used, the
+<i>capture_top</i> field contains one more than the number of the highest
+numbered captured substring so far. If no substrings have been captured, the
+value of <i>capture_top</i> is one. This is always the case when the DFA
+functions are used, because they do not support captured substrings.
</P>
<P>
The <i>capture_last</i> field contains the number of the most recently captured
substring. If no substrings have been captured, its value is -1. This is always
-the case when <b>pcre_dfa_exec()</b> is used.
+the case for the DFA matching functions.
</P>
<P>
-The <i>callout_data</i> field contains a value that is passed to
-<b>pcre_exec()</b> or <b>pcre_dfa_exec()</b> specifically so that it can be
-passed back in callouts. It is passed in the <i>pcre_callout</i> field of the
-<b>pcre_extra</b> data structure. If no such data was passed, the value of
-<i>callout_data</i> in a <b>pcre_callout</b> block is NULL. There is a
-description of the <b>pcre_extra</b> structure in the
+The <i>callout_data</i> field contains a value that is passed to a matching
+function specifically so that it can be passed back in callouts. It is passed
+in the <i>callout_data</i> field of a <b>pcre_extra</b> or <b>pcre16_extra</b>
+data structure. If no such data was passed, the value of <i>callout_data</i> in
+a callout block is NULL. There is a description of the <b>pcre_extra</b>
+structure in the
<a href="pcreapi.html"><b>pcreapi</b></a>
documentation.
</P>
<P>
-The <i>pattern_position</i> field is present from version 1 of the
-<i>pcre_callout</i> structure. It contains the offset to the next item to be
-matched in the pattern string.
+The <i>pattern_position</i> field is present from version 1 of the callout
+structure. It contains the offset to the next item to be matched in the pattern
+string.
</P>
<P>
-The <i>next_item_length</i> field is present from version 1 of the
-<i>pcre_callout</i> structure. It contains the length of the next item to be
-matched in the pattern string. When the callout immediately precedes an
-alternation bar, a closing parenthesis, or the end of the pattern, the length
-is zero. When the callout precedes an opening parenthesis, the length is that
-of the entire subpattern.
+The <i>next_item_length</i> field is present from version 1 of the callout
+structure. It contains the length of the next item to be matched in the pattern
+string. When the callout immediately precedes an alternation bar, a closing
+parenthesis, or the end of the pattern, the length is zero. When the callout
+precedes an opening parenthesis, the length is that of the entire subpattern.
</P>
<P>
The <i>pattern_position</i> and <i>next_item_length</i> fields are intended to
@@ -187,12 +191,12 @@ help in distinguishing between different automatic callouts, which all have the
same callout number. However, they are set for all callouts.
</P>
<P>
-The <i>mark</i> field is present from version 2 of the <i>pcre_callout</i>
-structure. In callouts from <b>pcre_exec()</b> it contains a pointer to the
-zero-terminated name of the most recently passed (*MARK), (*PRUNE), or (*THEN)
-item in the match, or NULL if no such items have been passed. Instances of
-(*PRUNE) or (*THEN) without a name do not obliterate a previous (*MARK). In
-callouts from <b>pcre_dfa_exec()</b> this field always contains NULL.
+The <i>mark</i> field is present from version 2 of the callout structure. In
+callouts from <b>pcre_exec()</b> or <b>pcre16_exec()</b> it contains a pointer to
+the zero-terminated name of the most recently passed (*MARK), (*PRUNE), or
+(*THEN) item in the match, or NULL if no such items have been passed. Instances
+of (*PRUNE) or (*THEN) without a name do not obliterate a previous (*MARK). In
+callouts from the DFA matching functions this field always contains NULL.
</P>
<br><a name="SEC4" href="#TOC1">RETURN VALUES</a><br>
<P>
@@ -200,8 +204,7 @@ The external callout function returns an integer to PCRE. If the value is zero,
matching proceeds as normal. If the value is greater than zero, matching fails
at the current point, but the testing of other matching possibilities goes
ahead, just as if a lookahead assertion had failed. If the value is less than
-zero, the match is abandoned, and <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
-returns the negative value.
+zero, the match is abandoned, the matching function returns the negative value.
</P>
<P>
Negative values should normally be chosen from the set of PCRE_ERROR_xxx
@@ -220,9 +223,9 @@ Cambridge CB2 3QH, England.
</P>
<br><a name="SEC6" href="#TOC1">REVISION</a><br>
<P>
-Last updated: 30 November 2011
+Last updated: 08 Janurary 2012
<br>
-Copyright &copy; 1997-2011 University of Cambridge.
+Copyright &copy; 1997-2012 University of Cambridge.
<br>
<p>
Return to the <a href="index.html">PCRE index page</a>.
diff --git a/doc/html/pcrecompat.html b/doc/html/pcrecompat.html
index 4e5e18b..740f0fe 100644
--- a/doc/html/pcrecompat.html
+++ b/doc/html/pcrecompat.html
@@ -21,8 +21,8 @@ regular expressions. The differences described here are with respect to Perl
versions 5.10 and above.
</P>
<P>
-1. PCRE has only a subset of Perl's UTF-8 and Unicode support. Details of what
-it does have are given in the
+1. PCRE has only a subset of Perl's Unicode support. Details of what it does
+have are given in the
<a href="pcreunicode.html"><b>pcreunicode</b></a>
page.
</P>
@@ -181,8 +181,8 @@ different hosts that have the other endianness. However, this does not apply to
optimized data created by the just-in-time compiler.
<br>
<br>
-(k) The alternative matching function (<b>pcre_dfa_exec()</b>) matches in a
-different way and is not Perl-compatible.
+(k) The alternative matching functions (<b>pcre_dfa_exec()</b> and
+<b>pcre16_dfa_exec()</b>) match in a different way and are not Perl-compatible.
<br>
<br>
(l) PCRE recognizes some special sequences such as (*CR) at the start of
@@ -203,9 +203,9 @@ Cambridge CB2 3QH, England.
REVISION
</b><br>
<P>
-Last updated: 14 November 2011
+Last updated: 08 Januray 2012
<br>
-Copyright &copy; 1997-2011 University of Cambridge.
+Copyright &copy; 1997-2012 University of Cambridge.
<br>
<p>
Return to the <a href="index.html">PCRE index page</a>.
diff --git a/doc/html/pcrecpp.html b/doc/html/pcrecpp.html
index 0ef2d4f..2c5879a 100644
--- a/doc/html/pcrecpp.html
+++ b/doc/html/pcrecpp.html
@@ -35,7 +35,8 @@ man page, in case the conversion went wrong.
The C++ wrapper for PCRE was provided by Google Inc. Some additional
functionality was added by Giuseppe Maxia. This brief man page was constructed
from the notes in the <i>pcrecpp.h</i> file, which should be consulted for
-further details.
+further details. Note that the C++ wrapper supports only the original 8-bit
+PCRE library. There is no 16-bit support at present.
</P>
<br><a name="SEC3" href="#TOC1">MATCHING INTERFACE</a><br>
<P>
@@ -360,9 +361,7 @@ Copyright &copy; 2007 Google Inc.
</P>
<br><a name="SEC12" href="#TOC1">REVISION</a><br>
<P>
-Last updated: 17 March 2009
-<br>
-Minor typo fixed: 25 July 2011
+Last updated: 08 January 2012
<br>
<p>
Return to the <a href="index.html">PCRE index page</a>.
diff --git a/doc/html/pcrejit.html b/doc/html/pcrejit.html
index 7411ecf..a604157 100644
--- a/doc/html/pcrejit.html
+++ b/doc/html/pcrejit.html
@@ -14,35 +14,44 @@ man page, in case the conversion went wrong.
<br>
<ul>
<li><a name="TOC1" href="#SEC1">PCRE JUST-IN-TIME COMPILER SUPPORT</a>
-<li><a name="TOC2" href="#SEC2">AVAILABILITY OF JIT SUPPORT</a>
-<li><a name="TOC3" href="#SEC3">SIMPLE USE OF JIT</a>
-<li><a name="TOC4" href="#SEC4">UNSUPPORTED OPTIONS AND PATTERN ITEMS</a>
-<li><a name="TOC5" href="#SEC5">RETURN VALUES FROM JIT EXECUTION</a>
-<li><a name="TOC6" href="#SEC6">SAVING AND RESTORING COMPILED PATTERNS</a>
-<li><a name="TOC7" href="#SEC7">CONTROLLING THE JIT STACK</a>
-<li><a name="TOC8" href="#SEC8">JIT STACK FAQ</a>
-<li><a name="TOC9" href="#SEC9">EXAMPLE CODE</a>
-<li><a name="TOC10" href="#SEC10">SEE ALSO</a>
-<li><a name="TOC11" href="#SEC11">AUTHOR</a>
-<li><a name="TOC12" href="#SEC12">REVISION</a>
+<li><a name="TOC2" href="#SEC2">8-BIT and 16-BIT SUPPORT</a>
+<li><a name="TOC3" href="#SEC3">AVAILABILITY OF JIT SUPPORT</a>
+<li><a name="TOC4" href="#SEC4">SIMPLE USE OF JIT</a>
+<li><a name="TOC5" href="#SEC5">UNSUPPORTED OPTIONS AND PATTERN ITEMS</a>
+<li><a name="TOC6" href="#SEC6">RETURN VALUES FROM JIT EXECUTION</a>
+<li><a name="TOC7" href="#SEC7">SAVING AND RESTORING COMPILED PATTERNS</a>
+<li><a name="TOC8" href="#SEC8">CONTROLLING THE JIT STACK</a>
+<li><a name="TOC9" href="#SEC9">JIT STACK FAQ</a>
+<li><a name="TOC10" href="#SEC10">EXAMPLE CODE</a>
+<li><a name="TOC11" href="#SEC11">SEE ALSO</a>
+<li><a name="TOC12" href="#SEC12">AUTHOR</a>
+<li><a name="TOC13" href="#SEC13">REVISION</a>
</ul>
<br><a name="SEC1" href="#TOC1">PCRE JUST-IN-TIME COMPILER SUPPORT</a><br>
<P>
Just-in-time compiling is a heavyweight optimization that can greatly speed up
pattern matching. However, it comes at the cost of extra processing before the
match is performed. Therefore, it is of most benefit when the same pattern is
-going to be matched many times. This does not necessarily mean many calls of
-\fPpcre_exec()\fP; if the pattern is not anchored, matching attempts may take
-place many times at various positions in the subject, even for a single call to
-<b>pcre_exec()</b>. If the subject string is very long, it may still pay to use
-JIT for one-off matches.
+going to be matched many times. This does not necessarily mean many calls of a
+matching function; if the pattern is not anchored, matching attempts may take
+place many times at various positions in the subject, even for a single call.
+Therefore, if the subject string is very long, it may still pay to use JIT for
+one-off matches.
</P>
<P>
-JIT support applies only to the traditional matching function,
-<b>pcre_exec()</b>. It does not apply when <b>pcre_dfa_exec()</b> is being used.
-The code for this support was written by Zoltan Herczeg.
+JIT support applies only to the traditional Perl-compatible matching function.
+It does not apply when the DFA matching function is being used. The code for
+this support was written by Zoltan Herczeg.
</P>
-<br><a name="SEC2" href="#TOC1">AVAILABILITY OF JIT SUPPORT</a><br>
+<br><a name="SEC2" href="#TOC1">8-BIT and 16-BIT SUPPORT</a><br>
+<P>
+JIT support is available for both the 8-bit and 16-bit PCRE libraries. To keep
+this documentation simple, only the 8-bit interface is described in what
+follows. If you are using the 16-bit library, substitute the 16-bit functions
+and 16-bit structures (for example, <i>pcre16_jit_stack</i> instead of
+<i>pcre_jit_stack</i>).
+</P>
+<br><a name="SEC3" href="#TOC1">AVAILABILITY OF JIT SUPPORT</a><br>
<P>
JIT support is an optional feature of PCRE. The "configure" option --enable-jit
(or equivalent CMake option) must be set when PCRE is built if you want to use
@@ -51,7 +60,7 @@ JIT. The support is limited to the following hardware platforms:
ARM v5, v7, and Thumb2
Intel x86 32-bit and 64-bit
MIPS 32-bit
- Power PC 32-bit and 64-bit (experimental)
+ Power PC 32-bit and 64-bit
</pre>
The Power PC support is designated as experimental because it has not been
fully tested. If --enable-jit is set on an unsupported platform, compilation
@@ -70,7 +79,7 @@ than 8.20, but you want to use JIT when it is available, you can test
the values of PCRE_MAJOR and PCRE_MINOR, or the existence of a JIT macro such
as PCRE_CONFIG_JIT, for compile-time control of your code.
</P>
-<br><a name="SEC3" href="#TOC1">SIMPLE USE OF JIT</a><br>
+<br><a name="SEC4" href="#TOC1">SIMPLE USE OF JIT</a><br>
<P>
You have to do two things to make use of the JIT support in the simplest way:
<pre>
@@ -128,7 +137,7 @@ JIT compiler was not able to handle the pattern.
Once a pattern has been studied, with or without JIT, it can be used as many
times as you like for matching different subject strings.
</P>
-<br><a name="SEC4" href="#TOC1">UNSUPPORTED OPTIONS AND PATTERN ITEMS</a><br>
+<br><a name="SEC5" href="#TOC1">UNSUPPORTED OPTIONS AND PATTERN ITEMS</a><br>
<P>
The only <b>pcre_exec()</b> options that are supported for JIT execution are
PCRE_NO_UTF8_CHECK, PCRE_NOTBOL, PCRE_NOTEOL, PCRE_NOTEMPTY, and
@@ -148,7 +157,7 @@ The unsupported pattern items are:
</pre>
Support for some of these may be added in future.
</P>
-<br><a name="SEC5" href="#TOC1">RETURN VALUES FROM JIT EXECUTION</a><br>
+<br><a name="SEC6" href="#TOC1">RETURN VALUES FROM JIT EXECUTION</a><br>
<P>
When a pattern is matched using JIT execution, the return values are the same
as those given by the interpretive <b>pcre_exec()</b> code, with the addition of
@@ -166,7 +175,7 @@ when JIT is not used, but the details of exactly what is counted are not the
same. The PCRE_ERROR_RECURSIONLIMIT error code is never returned by JIT
execution.
</P>
-<br><a name="SEC6" href="#TOC1">SAVING AND RESTORING COMPILED PATTERNS</a><br>
+<br><a name="SEC7" href="#TOC1">SAVING AND RESTORING COMPILED PATTERNS</a><br>
<P>
The code that is generated by the JIT compiler is architecture-specific, and is
also position dependent. For those reasons it cannot be saved (in a file or
@@ -179,7 +188,7 @@ restored pattern, and thereby recreate the JIT data, but because JIT
compilation uses significant resources, it is probably not worth doing this;
you might as well recompile the original pattern.
<a name="stackcontrol"></a></P>
-<br><a name="SEC7" href="#TOC1">CONTROLLING THE JIT STACK</a><br>
+<br><a name="SEC8" href="#TOC1">CONTROLLING THE JIT STACK</a><br>
<P>
When the compiled JIT code runs, it needs a block of memory to use as a stack.
By default, it uses 32K on the machine stack. However, some large or
@@ -256,7 +265,7 @@ and <b>pcre_assign_jit_stack()</b> does nothing unless the <b>extra</b> argument
is non-NULL and points to a <b>pcre_extra</b> block that is the result of a
successful study with PCRE_STUDY_JIT_COMPILE.
<a name="stackfaq"></a></P>
-<br><a name="SEC8" href="#TOC1">JIT STACK FAQ</a><br>
+<br><a name="SEC9" href="#TOC1">JIT STACK FAQ</a><br>
<P>
(1) Why do we need JIT stacks?
<br>
@@ -334,7 +343,7 @@ stack handling?
No, thanks to Windows. If POSIX threads were used everywhere, we could throw
out this complicated API.
</P>
-<br><a name="SEC9" href="#TOC1">EXAMPLE CODE</a><br>
+<br><a name="SEC10" href="#TOC1">EXAMPLE CODE</a><br>
<P>
This is a single-threaded example that specifies a JIT stack without using a
callback.
@@ -359,11 +368,11 @@ callback.
</PRE>
</P>
-<br><a name="SEC10" href="#TOC1">SEE ALSO</a><br>
+<br><a name="SEC11" href="#TOC1">SEE ALSO</a><br>
<P>
<b>pcreapi</b>(3)
</P>
-<br><a name="SEC11" href="#TOC1">AUTHOR</a><br>
+<br><a name="SEC12" href="#TOC1">AUTHOR</a><br>
<P>
Philip Hazel (FAQ by Zoltan Herczeg)
<br>
@@ -372,11 +381,11 @@ University Computing Service
Cambridge CB2 3QH, England.
<br>
</P>
-<br><a name="SEC12" href="#TOC1">REVISION</a><br>
+<br><a name="SEC13" href="#TOC1">REVISION</a><br>
<P>
-Last updated: 26 November 2011
+Last updated: 08 January 2012
<br>
-Copyright &copy; 1997-2011 University of Cambridge.
+Copyright &copy; 1997-2012 University of Cambridge.
<br>
<p>
Return to the <a href="index.html">PCRE index page</a>.
diff --git a/doc/html/pcrelimits.html b/doc/html/pcrelimits.html
index 2cab81f..94c554e 100644
--- a/doc/html/pcrelimits.html
+++ b/doc/html/pcrelimits.html
@@ -20,13 +20,14 @@ There are some size limitations in PCRE but it is hoped that they will never in
practice be relevant.
</P>
<P>
-The maximum length of a compiled pattern is 65539 (sic) bytes if PCRE is
-compiled with the default internal linkage size of 2. If you want to process
+The maximum length of a compiled pattern is approximately 64K data units (bytes
+for the 8-bit library, 16-bit units for the 16-bit library) if PCRE is compiled
+with the default internal linkage size of 2 bytes. If you want to process
regular expressions that are truly enormous, you can compile PCRE with an
-internal linkage size of 3 or 4 (see the <b>README</b> file in the source
-distribution and the
+internal linkage size of 3 or 4 (when building the 16-bit library, 3 is rounded
+up to 4). See the <b>README</b> file in the source distribution and the
<a href="pcrebuild.html"><b>pcrebuild</b></a>
-documentation for details). In these cases the limit is substantially larger.
+documentation for details. In these cases the limit is substantially larger.
However, the speed of execution is slower.
</P>
<P>
@@ -71,9 +72,9 @@ Cambridge CB2 3QH, England.
REVISION
</b><br>
<P>
-Last updated: 30 November 2011
+Last updated: 08 January 2012
<br>
-Copyright &copy; 1997-2011 University of Cambridge.
+Copyright &copy; 1997-2012 University of Cambridge.
<br>
<p>
Return to the <a href="index.html">PCRE index page</a>.
diff --git a/doc/html/pcrematching.html b/doc/html/pcrematching.html
index ad17c98..5cd41ae 100644
--- a/doc/html/pcrematching.html
+++ b/doc/html/pcrematching.html
@@ -26,15 +26,18 @@ man page, in case the conversion went wrong.
<P>
This document describes the two different algorithms that are available in PCRE
for matching a compiled regular expression against a given subject string. The
-"standard" algorithm is the one provided by the <b>pcre_exec()</b> function.
-This works in the same was as Perl's matching function, and provides a
-Perl-compatible matching operation.
+"standard" algorithm is the one provided by the <b>pcre_exec()</b> and
+<b>pcre16_exec()</b> functions. These work in the same was as Perl's matching
+function, and provide a Perl-compatible matching operation. The just-in-time
+(JIT) optimization that is described in the
+<a href="pcrejit.html"><b>pcrejit</b></a>
+documentation is compatible with these functions.
</P>
<P>
-An alternative algorithm is provided by the <b>pcre_dfa_exec()</b> function;
-this operates in a different way, and is not Perl-compatible. It has advantages
-and disadvantages compared with the standard algorithm, and these are described
-below.
+An alternative algorithm is provided by the <b>pcre_dfa_exec()</b> and
+<b>pcre16_dfa_exec()</b> functions; they operate in a different way, and are not
+Perl-compatible. This alternative has advantages and disadvantages compared
+with the standard algorithm, and these are described below.
</P>
<P>
When there is only one possible way in which a given subject string can match a
@@ -163,10 +166,10 @@ and not on others), is not supported. It causes an error if encountered.
always 1, and the value of the <i>capture_last</i> field is always -1.
</P>
<P>
-7. The \C escape sequence, which (in the standard algorithm) matches a single
-byte, even in UTF-8 mode, is not supported in UTF-8 mode, because the
-alternative algorithm moves through the subject string one character at a time,
-for all active paths through the tree.
+7. The \C escape sequence, which (in the standard algorithm) always matches a
+single data unit, even in UTF-8 or UTF-16 modes, is not supported in these
+modes, because the alternative algorithm moves through the subject string one
+character (not data unit) at a time, for all active paths through the tree.
</P>
<P>
8. Except for (*FAIL), the backtracking control verbs such as (*PRUNE) are not
@@ -184,11 +187,11 @@ callouts.
</P>
<P>
2. Because the alternative algorithm scans the subject string just once, and
-never needs to backtrack, it is possible to pass very long subject strings to
-the matching function in several pieces, checking for partial matching each
-time. Although it is possible to do multi-segment matching using the standard
-algorithm (<b>pcre_exec()</b>), by retaining partially matched substrings, it is
-more complicated. The
+never needs to backtrack (except for lookbehinds), it is possible to pass very
+long subject strings to the matching function in several pieces, checking for
+partial matching each time. Although it is possible to do multi-segment
+matching using the standard algorithm by retaining partially matched
+substrings, it is more complicated. The
<a href="pcrepartial.html"><b>pcrepartial</b></a>
documentation gives details of partial matching and discusses multi-segment
matching.
@@ -220,9 +223,9 @@ Cambridge CB2 3QH, England.
</P>
<br><a name="SEC8" href="#TOC1">REVISION</a><br>
<P>
-Last updated: 19 November 2011
+Last updated: 08 January 2012
<br>
-Copyright &copy; 1997-2010 University of Cambridge.
+Copyright &copy; 1997-2012 University of Cambridge.
<br>
<p>
Return to the <a href="index.html">PCRE index page</a>.
diff --git a/doc/html/pcrepartial.html b/doc/html/pcrepartial.html
index 1c8cdf2..40cdf97 100644
--- a/doc/html/pcrepartial.html
+++ b/doc/html/pcrepartial.html
@@ -14,24 +14,24 @@ man page, in case the conversion went wrong.
<br>
<ul>
<li><a name="TOC1" href="#SEC1">PARTIAL MATCHING IN PCRE</a>
-<li><a name="TOC2" href="#SEC2">PARTIAL MATCHING USING pcre_exec()</a>
-<li><a name="TOC3" href="#SEC3">PARTIAL MATCHING USING pcre_dfa_exec()</a>
+<li><a name="TOC2" href="#SEC2">PARTIAL MATCHING USING pcre_exec() OR pcre16_exec()</a>
+<li><a name="TOC3" href="#SEC3">PARTIAL MATCHING USING pcre_dfa_exec() OR pcre16_dfa_exec()</a>
<li><a name="TOC4" href="#SEC4">PARTIAL MATCHING AND WORD BOUNDARIES</a>
<li><a name="TOC5" href="#SEC5">FORMERLY RESTRICTED PATTERNS</a>
<li><a name="TOC6" href="#SEC6">EXAMPLE OF PARTIAL MATCHING USING PCRETEST</a>
-<li><a name="TOC7" href="#SEC7">MULTI-SEGMENT MATCHING WITH pcre_dfa_exec()</a>
-<li><a name="TOC8" href="#SEC8">MULTI-SEGMENT MATCHING WITH pcre_exec()</a>
+<li><a name="TOC7" href="#SEC7">MULTI-SEGMENT MATCHING WITH pcre_dfa_exec() OR pcre16_dfa_exec()</a>
+<li><a name="TOC8" href="#SEC8">MULTI-SEGMENT MATCHING WITH pcre_exec() OR pcre16_exec()</a>
<li><a name="TOC9" href="#SEC9">ISSUES WITH MULTI-SEGMENT MATCHING</a>
<li><a name="TOC10" href="#SEC10">AUTHOR</a>
<li><a name="TOC11" href="#SEC11">REVISION</a>
</ul>
<br><a name="SEC1" href="#TOC1">PARTIAL MATCHING IN PCRE</a><br>
<P>
-In normal use of PCRE, if the subject string that is passed to
-<b>pcre_exec()</b> or <b>pcre_dfa_exec()</b> matches as far as it goes, but is
-too short to match the entire pattern, PCRE_ERROR_NOMATCH is returned. There
-are circumstances where it might be helpful to distinguish this case from other
-cases in which there is no match.
+In normal use of PCRE, if the subject string that is passed to a matching
+function matches as far as it goes, but is too short to match the entire
+pattern, PCRE_ERROR_NOMATCH is returned. There are circumstances where it might
+be helpful to distinguish this case from other cases in which there is no
+match.
</P>
<P>
Consider, for example, an application where a human is required to type in data
@@ -50,42 +50,41 @@ long and is not all available at once.
</P>
<P>
PCRE supports partial matching by means of the PCRE_PARTIAL_SOFT and
-PCRE_PARTIAL_HARD options, which can be set when calling <b>pcre_exec()</b> or
-<b>pcre_dfa_exec()</b>. For backwards compatibility, PCRE_PARTIAL is a synonym
-for PCRE_PARTIAL_SOFT. The essential difference between the two options is
-whether or not a partial match is preferred to an alternative complete match,
-though the details differ between the two matching functions. If both options
+PCRE_PARTIAL_HARD options, which can be set when calling any of the matching
+functions. For backwards compatibility, PCRE_PARTIAL is a synonym for
+PCRE_PARTIAL_SOFT. The essential difference between the two options is whether
+or not a partial match is preferred to an alternative complete match, though
+the details differ between the two types of matching function. If both options
are set, PCRE_PARTIAL_HARD takes precedence.
</P>
<P>
-Setting a partial matching option for <b>pcre_exec()</b> disables the use of any
-just-in-time code that was set up by calling <b>pcre_study()</b> with the
+Setting a partial matching option disables the use of any just-in-time code
+that was set up by studying the compiled pattern with the
PCRE_STUDY_JIT_COMPILE option. It also disables two of PCRE's standard
-optimizations. PCRE remembers the last literal byte in a pattern, and abandons
-matching immediately if such a byte is not present in the subject string. This
+optimizations. PCRE remembers the last literal data unit in a pattern, and
+abandons matching immediately if it is not present in the subject string. This
optimization cannot be used for a subject string that might match only
partially. If the pattern was studied, PCRE knows the minimum length of a
matching string, and does not bother to run the matching function on shorter
strings. This optimization is also disabled for partial matching.
</P>
-<br><a name="SEC2" href="#TOC1">PARTIAL MATCHING USING pcre_exec()</a><br>
+<br><a name="SEC2" href="#TOC1">PARTIAL MATCHING USING pcre_exec() OR pcre16_exec()</a><br>
<P>
-A partial match occurs during a call to <b>pcre_exec()</b> when the end of the
-subject string is reached successfully, but matching cannot continue because
-more characters are needed. However, at least one character in the subject must
-have been inspected. This character need not form part of the final matched
-string; lookbehind assertions and the \K escape sequence provide ways of
-inspecting characters before the start of a matched substring. The requirement
-for inspecting at least one character exists because an empty string can always
-be matched; without such a restriction there would always be a partial match of
-an empty string at the end of the subject.
+A partial match occurs during a call to <b>pcre_exec()</b> or
+<b>pcre16_exec()</b> when the end of the subject string is reached successfully,
+but matching cannot continue because more characters are needed. However, at
+least one character in the subject must have been inspected. This character
+need not form part of the final matched string; lookbehind assertions and the
+\K escape sequence provide ways of inspecting characters before the start of a
+matched substring. The requirement for inspecting at least one character exists
+because an empty string can always be matched; without such a restriction there
+would always be a partial match of an empty string at the end of the subject.
</P>
<P>
-If there are at least two slots in the offsets vector when <b>pcre_exec()</b>
-returns with a partial match, the first slot is set to the offset of the
-earliest character that was inspected when the partial match was found. For
-convenience, the second offset points to the end of the subject so that a
-substring can easily be identified.
+If there are at least two slots in the offsets vector when a partial match is
+returned, the first slot is set to the offset of the earliest character that
+was inspected. For convenience, the second offset points to the end of the
+subject so that a substring can easily be identified.
</P>
<P>
For the majority of patterns, the first offset identifies the start of the
@@ -105,13 +104,14 @@ What happens when a partial match is identified depends on which of the two
partial matching options are set.
</P>
<br><b>
-PCRE_PARTIAL_SOFT with pcre_exec()
+PCRE_PARTIAL_SOFT WITH pcre_exec() OR pcre16_exec()
</b><br>
<P>
-If PCRE_PARTIAL_SOFT is set when <b>pcre_exec()</b> identifies a partial match,
-the partial match is remembered, but matching continues as normal, and other
-alternatives in the pattern are tried. If no complete match can be found,
-<b>pcre_exec()</b> returns PCRE_ERROR_PARTIAL instead of PCRE_ERROR_NOMATCH.
+If PCRE_PARTIAL_SOFT is set when <b>pcre_exec()</b> or <b>pcre16_exec()</b>
+identifies a partial match, the partial match is remembered, but matching
+continues as normal, and other alternatives in the pattern are tried. If no
+complete match can be found, PCRE_ERROR_PARTIAL is returned instead of
+PCRE_ERROR_NOMATCH.
</P>
<P>
This option is "soft" because it prefers a complete match over a partial match.
@@ -134,22 +134,24 @@ example, there are two partial matches, because "dog" on its own partially
matches the second alternative.)
</P>
<br><b>
-PCRE_PARTIAL_HARD with pcre_exec()
+PCRE_PARTIAL_HARD WITH pcre_exec() OR pcre16_exec()
</b><br>
<P>
-If PCRE_PARTIAL_HARD is set for <b>pcre_exec()</b>, it returns
-PCRE_ERROR_PARTIAL as soon as a partial match is found, without continuing to
-search for possible complete matches. This option is "hard" because it prefers
-an earlier partial match over a later complete match. For this reason, the
-assumption is made that the end of the supplied subject string may not be the
-true end of the available data, and so, if \z, \Z, \b, \B, or $ are
-encountered at the end of the subject, the result is PCRE_ERROR_PARTIAL.
-</P>
-<P>
-Setting PCRE_PARTIAL_HARD also affects the way <b>pcre_exec()</b> checks UTF-8
-subject strings for validity. Normally, an invalid UTF-8 sequence causes the
-error PCRE_ERROR_BADUTF8. However, in the special case of a truncated UTF-8
-character at the end of the subject, PCRE_ERROR_SHORTUTF8 is returned when
+If PCRE_PARTIAL_HARD is set for <b>pcre_exec()</b> or <b>pcre16_exec()</b>,
+PCRE_ERROR_PARTIAL is returned as soon as a partial match is found, without
+continuing to search for possible complete matches. This option is "hard"
+because it prefers an earlier partial match over a later complete match. For
+this reason, the assumption is made that the end of the supplied subject string
+may not be the true end of the available data, and so, if \z, \Z, \b, \B,
+or $ are encountered at the end of the subject, the result is
+PCRE_ERROR_PARTIAL.
+</P>
+<P>
+Setting PCRE_PARTIAL_HARD also affects the way UTF-8 and UTF-16
+subject strings are checked for validity. Normally, an invalid sequence
+causes the error PCRE_ERROR_BADUTF8 or PCRE_ERROR_BADUTF16. However, in the
+special case of a truncated character at the end of the subject,
+PCRE_ERROR_SHORTUTF8 or PCRE_ERROR_SHORTUTF16 is returned when
PCRE_PARTIAL_HARD is set.
</P>
<br><b>
@@ -169,23 +171,23 @@ if the pattern is made ungreedy the result is different:
<pre>
/dog(sbody)??/
</pre>
-In this case the result is always a complete match because <b>pcre_exec()</b>
-finds that first, and it never continues after finding a match. It might be
-easier to follow this explanation by thinking of the two patterns like this:
+In this case the result is always a complete match because that is found first,
+and matching never continues after finding a complete match. It might be easier
+to follow this explanation by thinking of the two patterns like this:
<pre>
/dog(sbody)?/ is the same as /dogsbody|dog/
/dog(sbody)??/ is the same as /dog|dogsbody/
</pre>
-The second pattern will never match "dogsbody" when <b>pcre_exec()</b> is
-used, because it will always find the shorter match first.
+The second pattern will never match "dogsbody", because it will always find the
+shorter match first.
</P>
-<br><a name="SEC3" href="#TOC1">PARTIAL MATCHING USING pcre_dfa_exec()</a><br>
+<br><a name="SEC3" href="#TOC1">PARTIAL MATCHING USING pcre_dfa_exec() OR pcre16_dfa_exec()</a><br>
<P>
-The <b>pcre_dfa_exec()</b> function moves along the subject string character by
-character, without backtracking, searching for all possible matches
-simultaneously. If the end of the subject is reached before the end of the
-pattern, there is the possibility of a partial match, again provided that at
-least one character has been inspected.
+The DFA functions move along the subject string character by character, without
+backtracking, searching for all possible matches simultaneously. If the end of
+the subject is reached before the end of the pattern, there is the possibility
+of a partial match, again provided that at least one character has been
+inspected.
</P>
<P>
When PCRE_PARTIAL_SOFT is set, PCRE_ERROR_PARTIAL is returned only if there
@@ -196,16 +198,16 @@ partial match was found is set as the first matching string, provided there are
at least two slots in the offsets vector.
</P>
<P>
-Because <b>pcre_dfa_exec()</b> always searches for all possible matches, and
-there is no difference between greedy and ungreedy repetition, its behaviour is
-different from <b>pcre_exec</b> when PCRE_PARTIAL_HARD is set. Consider the
-string "dog" matched against the ungreedy pattern shown above:
+Because the DFA functions always search for all possible matches, and there is
+no difference between greedy and ungreedy repetition, their behaviour is
+different from the standard functions when PCRE_PARTIAL_HARD is set. Consider
+the string "dog" matched against the ungreedy pattern shown above:
<pre>
/dog(sbody)??/
</pre>
-Whereas <b>pcre_exec()</b> stops as soon as it finds the complete match for
-"dog", <b>pcre_dfa_exec()</b> also finds the partial match for "dogsbody", and
-so returns that when PCRE_PARTIAL_HARD is set.
+Whereas the standard functions stop as soon as they find the complete match for
+"dog", the DFA functions also find the partial match for "dogsbody", and so
+return that when PCRE_PARTIAL_HARD is set.
</P>
<br><a name="SEC4" href="#TOC1">PARTIAL MATCHING AND WORD BOUNDARIES</a><br>
<P>
@@ -217,15 +219,11 @@ results. Consider this pattern:
</pre>
This matches "cat", provided there is a word boundary at either end. If the
subject string is "the cat", the comparison of the final "t" with a following
-character cannot take place, so a partial match is found. However,
-<b>pcre_exec()</b> carries on with normal matching, which matches \b at the end
-of the subject when the last character is a letter, thus finding a complete
-match. The result, therefore, is <i>not</i> PCRE_ERROR_PARTIAL. The same thing
-happens with <b>pcre_dfa_exec()</b>, because it also finds the complete match.
-</P>
-<P>
-Using PCRE_PARTIAL_HARD in this case does yield PCRE_ERROR_PARTIAL, because
-then the partial match takes precedence.
+character cannot take place, so a partial match is found. However, normal
+matching carries on, and \b matches at the end of the subject when the last
+character is a letter, so a complete match is found. The result, therefore, is
+<i>not</i> PCRE_ERROR_PARTIAL. Using PCRE_PARTIAL_HARD in this case does yield
+PCRE_ERROR_PARTIAL, because then the partial match takes precedence.
</P>
<br><a name="SEC5" href="#TOC1">FORMERLY RESTRICTED PATTERNS</a><br>
<P>
@@ -233,7 +231,7 @@ For releases of PCRE prior to 8.00, because of the way certain internal
optimizations were implemented in the <b>pcre_exec()</b> function, the
PCRE_PARTIAL option (predecessor of PCRE_PARTIAL_SOFT) could not be used with
all patterns. From release 8.00 onwards, the restrictions no longer apply, and
-partial matching with <b>pcre_exec()</b> can be requested for any pattern.
+partial matching with can be requested for any pattern.
</P>
<P>
Items that were formerly restricted were repeated single characters and
@@ -265,22 +263,21 @@ that uses the date example quoted above:
The first data string is matched completely, so <b>pcretest</b> shows the
matched substrings. The remaining four strings do not match the complete
pattern, but the first two are partial matches. Similar output is obtained
-when <b>pcre_dfa_exec()</b> is used.
+if DFA matching is used.
</P>
<P>
If the escape sequence \P is present more than once in a <b>pcretest</b> data
line, the PCRE_PARTIAL_HARD option is set for the match.
</P>
-<br><a name="SEC7" href="#TOC1">MULTI-SEGMENT MATCHING WITH pcre_dfa_exec()</a><br>
+<br><a name="SEC7" href="#TOC1">MULTI-SEGMENT MATCHING WITH pcre_dfa_exec() OR pcre16_dfa_exec()</a><br>
<P>
-When a partial match has been found using <b>pcre_dfa_exec()</b>, it is possible
-to continue the match by providing additional subject data and calling
-<b>pcre_dfa_exec()</b> again with the same compiled regular expression, this
-time setting the PCRE_DFA_RESTART option. You must pass the same working
-space as before, because this is where details of the previous partial match
-are stored. Here is an example using <b>pcretest</b>, using the \R escape
-sequence to set the PCRE_DFA_RESTART option (\D specifies the use of
-<b>pcre_dfa_exec()</b>):
+When a partial match has been found using a DFA matching function, it is
+possible to continue the match by providing additional subject data and calling
+the function again with the same compiled regular expression, this time setting
+the PCRE_DFA_RESTART option. You must pass the same working space as before,
+because this is where details of the previous partial match are stored. Here is
+an example using <b>pcretest</b>, using the \R escape sequence to set the
+PCRE_DFA_RESTART option (\D specifies the use of the DFA matching function):
<pre>
re&#62; /^\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d$/
data&#62; 23ja\P\D
@@ -297,33 +294,35 @@ program to do that if it needs to.
<P>
You can set the PCRE_PARTIAL_SOFT or PCRE_PARTIAL_HARD options with
PCRE_DFA_RESTART to continue partial matching over multiple segments. This
-facility can be used to pass very long subject strings to
-<b>pcre_dfa_exec()</b>.
-</P>
-<br><a name="SEC8" href="#TOC1">MULTI-SEGMENT MATCHING WITH pcre_exec()</a><br>
-<P>
-From release 8.00, <b>pcre_exec()</b> can also be used to do multi-segment
-matching. Unlike <b>pcre_dfa_exec()</b>, it is not possible to restart the
-previous match with a new segment of data. Instead, new data must be added to
-the previous subject string, and the entire match re-run, starting from the
-point where the partial match occurred. Earlier data can be discarded. It is
-best to use PCRE_PARTIAL_HARD in this situation, because it does not treat the
-end of a segment as the end of the subject when matching \z, \Z, \b, \B,
-and $. Consider an unanchored pattern that matches dates:
+facility can be used to pass very long subject strings to the DFA matching
+functions.
+</P>
+<br><a name="SEC8" href="#TOC1">MULTI-SEGMENT MATCHING WITH pcre_exec() OR pcre16_exec()</a><br>
+<P>
+From release 8.00, the standard matching functions can also be used to do
+multi-segment matching. Unlike the DFA functions, it is not possible to
+restart the previous match with a new segment of data. Instead, new data must
+be added to the previous subject string, and the entire match re-run, starting
+from the point where the partial match occurred. Earlier data can be discarded.
+</P>
+<P>
+It is best to use PCRE_PARTIAL_HARD in this situation, because it does not
+treat the end of a segment as the end of the subject when matching \z, \Z,
+\b, \B, and $. Consider an unanchored pattern that matches dates:
<pre>
re&#62; /\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d/
data&#62; The date is 23ja\P\P
Partial match: 23ja
</pre>
At this stage, an application could discard the text preceding "23ja", add on
-text from the next segment, and call <b>pcre_exec()</b> again. Unlike
-<b>pcre_dfa_exec()</b>, the entire matching string must always be available, and
+text from the next segment, and call the matching function again. Unlike the
+DFA matching functions the entire matching string must always be available, and
the complete matching process occurs for each call, so more memory and more
processing time is needed.
</P>
<P>
<b>Note:</b> If the pattern contains lookbehind assertions, or \K, or starts
-with \b or \B, the string that is returned for a partial match will include
+with \b or \B, the string that is returned for a partial match includes
characters that precede the partially matched string itself, because these must
be retained when adding on more characters for a subsequent matching attempt.
</P>
@@ -369,14 +368,14 @@ longer possible. Consider again this <b>pcretest</b> example:
0: dogsbody
1: dog
</pre>
-The first data line passes the string "dogsb" to <b>pcre_exec()</b>, setting the
-PCRE_PARTIAL_SOFT option. Although the string is a partial match for
-"dogsbody", the result is not PCRE_ERROR_PARTIAL, because the shorter string
-"dog" is a complete match. Similarly, when the subject is presented to
-<b>pcre_dfa_exec()</b> in several parts ("do" and "gsb" being the first two) the
-match stops when "dog" has been found, and it is not possible to continue. On
-the other hand, if "dogsbody" is presented as a single string,
-<b>pcre_dfa_exec()</b> finds both matches.
+The first data line passes the string "dogsb" to a standard matching function,
+setting the PCRE_PARTIAL_SOFT option. Although the string is a partial match
+for "dogsbody", the result is not PCRE_ERROR_PARTIAL, because the shorter
+string "dog" is a complete match. Similarly, when the subject is presented to
+a DFA matching function in several parts ("do" and "gsb" being the first two)
+the match stops when "dog" has been found, and it is not possible to continue.
+On the other hand, if "dogsbody" is presented as a single string, a DFA
+matching function finds both matches.
</P>
<P>
Because of these problems, it is best to use PCRE_PARTIAL_HARD when matching
@@ -390,10 +389,9 @@ multi-segment data. The example above then behaves differently:
data&#62; gsb\R\P\P\D
Partial match: gsb
</pre>
-4. Patterns that contain alternatives at the top level which do not all
-start with the same pattern item may not work as expected when
-PCRE_DFA_RESTART is used with <b>pcre_dfa_exec()</b>. For example, consider this
-pattern:
+4. Patterns that contain alternatives at the top level which do not all start
+with the same pattern item may not work as expected when PCRE_DFA_RESTART is
+used. For example, consider this pattern:
<pre>
1234|3789
</pre>
@@ -409,8 +407,8 @@ patterns or patterns such as:
1234|ABCD
</pre>
where no string can be a partial match for both alternatives. This is not a
-problem if <b>pcre_exec()</b> is used, because the entire match has to be rerun
-each time:
+problem if a standard matching function is used, because the entire match has
+to be rerun each time:
<pre>
re&#62; /1234|3789/
data&#62; ABC123\P\P
@@ -419,7 +417,7 @@ each time:
0: 3789
</pre>
Of course, instead of using PCRE_DFA_RESTART, the same technique of re-running
-the entire match can also be used with <b>pcre_dfa_exec()</b>. Another
+the entire match can also be used with the DFA matching functions. Another
possibility is to work with two buffers. If a partial match at offset <i>n</i>
in the first buffer is followed by "no match" when PCRE_DFA_RESTART is used on
the second buffer, you can then try a new match starting at offset <i>n+1</i> in
@@ -436,9 +434,9 @@ Cambridge CB2 3QH, England.
</P>
<br><a name="SEC11" href="#TOC1">REVISION</a><br>
<P>
-Last updated: 26 August 2011
+Last updated: 08 January 2012
<br>
-Copyright &copy; 1997-2011 University of Cambridge.
+Copyright &copy; 1997-2012 University of Cambridge.
<br>
<p>
Return to the <a href="index.html">PCRE index page</a>.
diff --git a/doc/html/pcrepattern.html b/doc/html/pcrepattern.html
index aa39d63..26c23f2 100644
--- a/doc/html/pcrepattern.html
+++ b/doc/html/pcrepattern.html
@@ -19,7 +19,7 @@ man page, in case the conversion went wrong.
<li><a name="TOC4" href="#SEC4">BACKSLASH</a>
<li><a name="TOC5" href="#SEC5">CIRCUMFLEX AND DOLLAR</a>
<li><a name="TOC6" href="#SEC6">FULL STOP (PERIOD, DOT) AND \N</a>
-<li><a name="TOC7" href="#SEC7">MATCHING A SINGLE BYTE</a>
+<li><a name="TOC7" href="#SEC7">MATCHING A SINGLE DATA UNIT</a>
<li><a name="TOC8" href="#SEC8">SQUARE BRACKETS AND CHARACTER CLASSES</a>
<li><a name="TOC9" href="#SEC9">POSIX CHARACTER CLASSES</a>
<li><a name="TOC10" href="#SEC10">VERTICAL BAR</a>
@@ -61,23 +61,26 @@ description of PCRE's regular expressions is intended as reference material.
</P>
<P>
The original operation of PCRE was on strings of one-byte characters. However,
-there is now also support for UTF-8 character strings. To use this,
-PCRE must be built to include UTF-8 support, and you must call
-<b>pcre_compile()</b> or <b>pcre_compile2()</b> with the PCRE_UTF8 option. There
-is also a special sequence that can be given at the start of a pattern:
+there is now also support for UTF-8 strings in the original library, and a
+second library that supports 16-bit and UTF-16 character strings. To use these
+features, PCRE must be built to include appropriate support. When using UTF
+strings you must either call the compiling function with the PCRE_UTF8 or
+PCRE_UTF16 option, or the pattern must start with one of these special
+sequences:
<pre>
(*UTF8)
+ (*UTF16)
</pre>
-Starting a pattern with this sequence is equivalent to setting the PCRE_UTF8
-option. This feature is not Perl-compatible. How setting UTF-8 mode affects
+Starting a pattern with such a sequence is equivalent to setting the relevant
+option. This feature is not Perl-compatible. How setting a UTF mode affects
pattern matching is mentioned in several places below. There is also a summary
-of UTF-8 features in the
+of features in the
<a href="pcreunicode.html"><b>pcreunicode</b></a>
page.
</P>
<P>
Another special sequence that may appear at the start of a pattern or in
-combination with (*UTF8) is:
+combination with (*UTF8) or (*UTF16) is:
<pre>
(*UCP)
</pre>
@@ -94,13 +97,13 @@ of newlines; they are described below.
</P>
<P>
The remainder of this document discusses the patterns that are supported by
-PCRE when its main matching function, <b>pcre_exec()</b>, is used.
-From release 6.0, PCRE offers a second matching function,
-<b>pcre_dfa_exec()</b>, which matches using a different algorithm that is not
-Perl-compatible. Some of the features discussed below are not available when
-<b>pcre_dfa_exec()</b> is used. The advantages and disadvantages of the
-alternative function, and how it differs from the normal function, are
-discussed in the
+PCRE when one its main matching functions, <b>pcre_exec()</b> (8-bit) or
+<b>pcre16_exec()</b> (16-bit), is used. PCRE also has alternative matching
+functions, <b>pcre_dfa_exec()</b> and <b>pcre16_dfa_exec()</b>, which match using
+a different algorithm that is not Perl-compatible. Some of the features
+discussed below are not available when DFA matching is used. The advantages and
+disadvantages of the alternative functions, and how they differ from the normal
+functions, are discussed in the
<a href="pcrematching.html"><b>pcrematching</b></a>
page.
<a name="newlines"></a></P>
@@ -126,9 +129,8 @@ string with one of the following five sequences:
(*ANYCRLF) any of the three above
(*ANY) all Unicode newline sequences
</pre>
-These override the default and the options given to <b>pcre_compile()</b> or
-<b>pcre_compile2()</b>. For example, on a Unix system where LF is the default
-newline sequence, the pattern
+These override the default and the options given to the compiling function. For
+example, on a Unix system where LF is the default newline sequence, the pattern
<pre>
(*CR)a.b
</pre>
@@ -158,13 +160,13 @@ corresponding characters in the subject. As a trivial example, the pattern
</pre>
matches a portion of a subject string that is identical to itself. When
caseless matching is specified (the PCRE_CASELESS option), letters are matched
-independently of case. In UTF-8 mode, PCRE always understands the concept of
+independently of case. In a UTF mode, PCRE always understands the concept of
case for characters whose values are less than 128, so caseless matching is
always possible. For characters with higher values, the concept of case is
supported if PCRE is compiled with Unicode property support, but not otherwise.
If you want to use caseless matching for characters 128 and above, you must
ensure that PCRE is compiled with Unicode property support as well as with
-UTF-8 support.
+UTF support.
</P>
<P>
The power of regular expressions comes from the ability to include alternatives
@@ -220,7 +222,7 @@ non-alphanumeric with backslash to specify that it stands for itself. In
particular, if you want to match a backslash, you write \\.
</P>
<P>
-In UTF-8 mode, only ASCII numbers and letters have any special meaning after a
+In a UTF mode, only ASCII numbers and letters have any special meaning after a
backslash. All other characters (in particular, those whose codepoints are
greater than 127) are treated as literals.
</P>
@@ -276,17 +278,22 @@ is converted to upper case. Then bit 6 of the character (hex 40) is inverted.
Thus \cz becomes hex 1A (z is 7A), but \c{ becomes hex 3B ({ is 7B), while
\c; becomes hex 7B (; is 3B). If the byte following \c has a value greater
than 127, a compile-time error occurs. This locks out non-ASCII characters in
-both byte mode and UTF-8 mode. (When PCRE is compiled in EBCDIC mode, all byte
-values are valid. A lower case letter is converted to upper case, and then the
-0xc0 bits are flipped.)
+all modes. (When PCRE is compiled in EBCDIC mode, all byte values are valid. A
+lower case letter is converted to upper case, and then the 0xc0 bits are
+flipped.)
</P>
<P>
By default, after \x, from zero to two hexadecimal digits are read (letters
can be in upper or lower case). Any number of hexadecimal digits may appear
-between \x{ and }, but the value of the character code must be less than 256
-in non-UTF-8 mode, and less than 2**31 in UTF-8 mode. That is, the maximum
-value in hexadecimal is 7FFFFFFF. Note that this is bigger than the largest
-Unicode code point, which is 10FFFF.
+between \x{ and }, but the character code is constrained as follows:
+<pre>
+ 8-bit non-UTF mode less than 0x100
+ 8-bit UTF-8 mode less than 0x10ffff and a valid codepoint
+ 16-bit non-UTF mode less than 0x10000
+ 16-bit UTF-16 mode less than 0x10ffff and a valid codepoint
+</pre>
+Invalid Unicode codepoints are the range 0xd800 to 0xdfff (the so-called
+"surrogate" codepoints).
</P>
<P>
If characters other than hexadecimal digits appear between \x{ and }, or if
@@ -328,9 +335,9 @@ following the discussion of
Inside a character class, or if the decimal number is greater than 9 and there
have not been that many capturing subpatterns, PCRE re-reads up to three octal
digits following the backslash, and uses them to generate a data character. Any
-subsequent digits stand for themselves. In non-UTF-8 mode, the value of a
-character specified in octal must be less than \400. In UTF-8 mode, values up
-to \777 are permitted. For example:
+subsequent digits stand for themselves. The value of the character is
+constrained in the same way as characters specified in hexadecimal.
+For example:
<pre>
\040 is another way of writing a space
\40 is the same, provided there are fewer than 40 previous capturing subpatterns
@@ -339,7 +346,7 @@ to \777 are permitted. For example:
\011 is always a tab
\0113 is a tab followed by the character "3"
\113 might be a back reference, otherwise the character with octal code 113
- \377 might be a back reference, otherwise the byte consisting entirely of 1 bits
+ \377 might be a back reference, otherwise the value 255 (decimal)
\81 is either a back reference, or a binary zero followed by the two characters "8" and "1"
</pre>
Note that octal values of 100 or greater must not be introduced by a leading
@@ -443,9 +450,9 @@ accented letters, and these are then matched by \w. The use of locales with
Unicode is discouraged.
</P>
<P>
-By default, in UTF-8 mode, characters with values greater than 128 never match
+By default, in a UTF mode, characters with values greater than 128 never match
\d, \s, or \w, and always match \D, \S, and \W. These sequences retain
-their original meanings from before UTF-8 support was available, mainly for
+their original meanings from before UTF support was available, mainly for
efficiency reasons. However, if PCRE is compiled with Unicode property support,
and the PCRE_UCP option is set, the behaviour is changed so that Unicode
properties are used to determine character types, as follows:
@@ -463,9 +470,8 @@ is noticeably slower when PCRE_UCP is set.
<P>
The sequences \h, \H, \v, and \V are features that were added to Perl at
release 5.10. In contrast to the other sequences, which match only ASCII
-characters by default, these always match certain high-valued codepoints in
-UTF-8 mode, whether or not PCRE_UCP is set. The horizontal space characters
-are:
+characters by default, these always match certain high-valued codepoints,
+whether or not PCRE_UCP is set. The horizontal space characters are:
<pre>
U+0009 Horizontal tab
U+0020 Space
@@ -496,14 +502,17 @@ The vertical space characters are:
U+0085 Next line
U+2028 Line separator
U+2029 Paragraph separator
-<a name="newlineseq"></a></PRE>
-</P>
+</pre>
+In 8-bit, non-UTF-8 mode, only the characters with codepoints less than 256 are
+relevant.
+<a name="newlineseq"></a></P>
<br><b>
Newline sequences
</b><br>
<P>
Outside a character class, by default, the escape sequence \R matches any
-Unicode newline sequence. In non-UTF-8 mode \R is equivalent to the following:
+Unicode newline sequence. In 8-bit non-UTF-8 mode \R is equivalent to the
+following:
<pre>
(?&#62;\r\n|\n|\x0b|\f|\r|\x85)
</pre>
@@ -516,7 +525,7 @@ line, U+0085). The two-character sequence is treated as a single unit that
cannot be split.
</P>
<P>
-In UTF-8 mode, two additional characters whose codepoints are greater than 255
+In other modes, two additional characters whose codepoints are greater than 255
are added: LS (line separator, U+2028) and PS (paragraph separator, U+2029).
Unicode character property support is not needed for these characters to be
recognized.
@@ -533,19 +542,19 @@ one of the following sequences:
(*BSR_ANYCRLF) CR, LF, or CRLF only
(*BSR_UNICODE) any Unicode newline sequence
</pre>
-These override the default and the options given to <b>pcre_compile()</b> or
-<b>pcre_compile2()</b>, but they can be overridden by options given to
-<b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>. Note that these special settings,
-which are not Perl-compatible, are recognized only at the very start of a
-pattern, and that they must be in upper case. If more than one of them is
-present, the last one is used. They can be combined with a change of newline
-convention; for example, a pattern can start with:
+These override the default and the options given to the compiling function, but
+they can themselves be overridden by options given to a matching function. Note
+that these special settings, which are not Perl-compatible, are recognized only
+at the very start of a pattern, and that they must be in upper case. If more
+than one of them is present, the last one is used. They can be combined with a
+change of newline convention; for example, a pattern can start with:
<pre>
(*ANY)(*BSR_ANYCRLF)
</pre>
-They can also be combined with the (*UTF8) or (*UCP) special sequences. Inside
-a character class, \R is treated as an unrecognized escape sequence, and so
-matches the letter "R" by default, but causes an error if PCRE_EXTRA is set.
+They can also be combined with the (*UTF8), (*UTF16), or (*UCP) special
+sequences. Inside a character class, \R is treated as an unrecognized escape
+sequence, and so matches the letter "R" by default, but causes an error if
+PCRE_EXTRA is set.
<a name="uniextseq"></a></P>
<br><b>
Unicode character properties
@@ -553,7 +562,7 @@ Unicode character properties
<P>
When PCRE is built with Unicode character property support, three additional
escape sequences that match characters with specific properties are available.
-When not in UTF-8 mode, these sequences are of course limited to testing
+When in 8-bit non-UTF-8 mode, these sequences are of course limited to testing
characters whose codepoints are less than 256, but they do work in this mode.
The extra escape sequences are:
<pre>
@@ -742,9 +751,9 @@ a modifier or "other".
</P>
<P>
The Cs (Surrogate) property applies only to characters in the range U+D800 to
-U+DFFF. Such characters are not valid in UTF-8 strings (see RFC 3629) and so
-cannot be tested by PCRE, unless UTF-8 validity checking has been turned off
-(see the discussion of PCRE_NO_UTF8_CHECK in the
+U+DFFF. Such characters are not valid in Unicode strings and so
+cannot be tested by PCRE, unless UTF validity checking has been turned off
+(see the discussion of PCRE_NO_UTF8_CHECK and PCRE_NO_UTF16_CHECK in the
<a href="pcreapi.html"><b>pcreapi</b></a>
page). Perl does not support the Cs property.
</P>
@@ -774,7 +783,7 @@ atomic group
<a href="#atomicgroup">(see below).</a>
Characters with the "mark" property are typically accents that affect the
preceding character. None of them have codepoints less than 256, so in
-non-UTF-8 mode \X matches any one character.
+8-bit non-UTF-8 mode \X matches any one character.
</P>
<P>
Note that recent versions of Perl have changed \X to match what Unicode calls
@@ -785,8 +794,7 @@ Matching characters by Unicode property is not fast, because PCRE has to search
a structure that contains data for over fifteen thousand characters. That is
why the traditional escape sequences such as \d and \w do not use Unicode
properties in PCRE by default, though you can make them do so by setting the
-PCRE_UCP option for <b>pcre_compile()</b> or by starting the pattern with
-(*UCP).
+PCRE_UCP option or by starting the pattern with (*UCP).
<a name="extraprops"></a></P>
<br><b>
PCRE's additional properties
@@ -865,7 +873,7 @@ escape sequence" error is generated instead.
A word boundary is a position in the subject string where the current character
and the previous character do not both match \w or \W (i.e. one matches
\w and the other matches \W), or the start or end of the string if the
-first or last character matches \w, respectively. In UTF-8 mode, the meanings
+first or last character matches \w, respectively. In a UTF mode, the meanings
of \w and \W can be changed by setting the PCRE_UCP option. When this is
done, it also affects \b and \B. Neither PCRE nor Perl has a separate "start
of word" or "end of word" metasequence. However, whatever follows \b normally
@@ -962,7 +970,7 @@ end of the subject in both modes, and if all branches of a pattern start with
<P>
Outside a character class, a dot in the pattern matches any one character in
the subject string except (by default) a character that signifies the end of a
-line. In UTF-8 mode, the matched character may be more than one byte long.
+line.
</P>
<P>
When a line ending is defined as a single character, dot never matches that
@@ -989,29 +997,30 @@ the PCRE_DOTALL option. In other words, it matches any character except one
that signifies the end of a line. Perl also uses \N to match characters by
name; PCRE does not support this.
</P>
-<br><a name="SEC7" href="#TOC1">MATCHING A SINGLE BYTE</a><br>
+<br><a name="SEC7" href="#TOC1">MATCHING A SINGLE DATA UNIT</a><br>
<P>
-Outside a character class, the escape sequence \C matches any one byte, both
-in and out of UTF-8 mode. Unlike a dot, it always matches line-ending
-characters. The feature is provided in Perl in order to match individual bytes
-in UTF-8 mode, but it is unclear how it can usefully be used. Because \C
-breaks up characters into individual bytes, matching one byte with \C in UTF-8
-mode means that the rest of the string may start with a malformed UTF-8
-character. This has undefined results, because PCRE assumes that it is dealing
-with valid UTF-8 strings (and by default it checks this at the start of
-processing unless the PCRE_NO_UTF8_CHECK option is used).
+Outside a character class, the escape sequence \C matches any one data unit,
+whether or not a UTF mode is set. In the 8-bit library, one data unit is one
+byte; in the 16-bit library it is a 16-bit unit. Unlike a dot, \C always
+matches line-ending characters. The feature is provided in Perl in order to
+match individual bytes in UTF-8 mode, but it is unclear how it can usefully be
+used. Because \C breaks up characters into individual data units, matching one
+unit with \C in a UTF mode means that the rest of the string may start with a
+malformed UTF character. This has undefined results, because PCRE assumes that
+it is dealing with valid UTF strings (and by default it checks this at the
+start of processing unless the PCRE_NO_UTF8_CHECK option is used).
</P>
<P>
PCRE does not allow \C to appear in lookbehind assertions
<a href="#lookbehind">(described below)</a>
-in UTF-8 mode, because this would make it impossible to calculate the length of
+in a UTF mode, because this would make it impossible to calculate the length of
the lookbehind.
</P>
<P>
-In general, the \C escape sequence is best avoided in UTF-8 mode. However, one
-way of using it that avoids the problem of malformed UTF-8 characters is to
-use a lookahead to check the length of the next character, as in this pattern
-(ignore white space and line breaks):
+In general, the \C escape sequence is best avoided. However, one
+way of using it that avoids the problem of malformed UTF characters is to use a
+lookahead to check the length of the next character, as in this pattern, which
+could be used with a UTF-8 string (ignore white space and line breaks):
<pre>
(?| (?=[\x00-\x7f])(\C) |
(?=[\x80-\x{7ff}])(\C)(\C) |
@@ -1036,12 +1045,12 @@ a member of the class, it should be the first data character in the class
(after an initial circumflex, if present) or escaped with a backslash.
</P>
<P>
-A character class matches a single character in the subject. In UTF-8 mode, the
-character may be more than one byte long. A matched character must be in the
-set of characters defined by the class, unless the first character in the class
-definition is a circumflex, in which case the subject character must not be in
-the set defined by the class. If a circumflex is actually required as a member
-of the class, ensure it is not the first character, or escape it with a
+A character class matches a single character in the subject. In a UTF mode, the
+character may be more than one data unit long. A matched character must be in
+the set of characters defined by the class, unless the first character in the
+class definition is a circumflex, in which case the subject character must not
+be in the set defined by the class. If a circumflex is actually required as a
+member of the class, ensure it is not the first character, or escape it with a
backslash.
</P>
<P>
@@ -1054,20 +1063,21 @@ string, and therefore it fails if the current pointer is at the end of the
string.
</P>
<P>
-In UTF-8 mode, characters with values greater than 255 can be included in a
-class as a literal string of bytes, or by using the \x{ escaping mechanism.
+In UTF-8 (UTF-16) mode, characters with values greater than 255 (0xffff) can be
+included in a class as a literal string of data units, or by using the \x{
+escaping mechanism.
</P>
<P>
When caseless matching is set, any letters in a class represent both their
upper case and lower case versions, so for example, a caseless [aeiou] matches
"A" as well as "a", and a caseless [^aeiou] does not match "A", whereas a
-caseful version would. In UTF-8 mode, PCRE always understands the concept of
+caseful version would. In a UTF mode, PCRE always understands the concept of
case for characters whose values are less than 128, so caseless matching is
always possible. For characters with higher values, the concept of case is
supported if PCRE is compiled with Unicode property support, but not otherwise.
-If you want to use caseless matching in UTF8-mode for characters 128 and above,
-you must ensure that PCRE is compiled with Unicode property support as well as
-with UTF-8 support.
+If you want to use caseless matching in a UTF mode for characters 128 and
+above, you must ensure that PCRE is compiled with Unicode property support as
+well as with UTF support.
</P>
<P>
Characters that might indicate line breaks are never treated in any special way
@@ -1093,16 +1103,15 @@ followed by two other characters. The octal or hexadecimal representation of
</P>
<P>
Ranges operate in the collating sequence of character values. They can also be
-used for characters specified numerically, for example [\000-\037]. In UTF-8
-mode, ranges can include characters whose values are greater than 255, for
-example [\x{100}-\x{2ff}].
+used for characters specified numerically, for example [\000-\037]. Ranges
+can include any characters that are valid for the current mode.
</P>
<P>
If a range that includes letters is used when caseless matching is set, it
matches the letters in either case. For example, [W-c] is equivalent to
-[][\\^_`wxyzabc], matched caselessly, and in non-UTF-8 mode, if character
+[][\\^_`wxyzabc], matched caselessly, and in a non-UTF mode, if character
tables for a French locale are in use, [\xc8-\xcb] matches accented E
-characters in both cases. In UTF-8 mode, PCRE supports the concept of case for
+characters in both cases. In UTF modes, PCRE supports the concept of case for
characters with values greater than 128 only when it is compiled with Unicode
property support.
</P>
@@ -1110,7 +1119,7 @@ property support.
The character escape sequences \d, \D, \h, \H, \p, \P, \s, \S, \v,
\V, \w, and \W may appear in a character class, and add the characters that
they match to the class. For example, [\dABCDEF] matches any hexadecimal
-digit. In UTF-8 mode, the PCRE_UCP option affects the meanings of \d, \s, \w
+digit. In UTF modes, the PCRE_UCP option affects the meanings of \d, \s, \w
and their upper case partners, just as it does when they appear outside a
character class, as described in the section entitled
<a href="#genericchartypes">"Generic character types"</a>
@@ -1179,7 +1188,7 @@ syntax [.ch.] and [=ch=] where "ch" is a "collating element", but these are not
supported, and an error is given if they are encountered.
</P>
<P>
-By default, in UTF-8 mode, characters with values greater than 128 do not match
+By default, in UTF modes, characters with values greater than 128 do not match
any of the POSIX character classes. However, if the PCRE_UCP option is passed
to <b>pcre_compile()</b>, some of the classes are changed so that Unicode
character properties are used. This is achieved by replacing the POSIX classes
@@ -1264,14 +1273,14 @@ behaviour otherwise.
</P>
<P>
<b>Note:</b> There are other PCRE-specific options that can be set by the
-application when the compile or match functions are called. In some cases the
-pattern can contain special leading sequences such as (*CRLF) to override what
-the application has set or what has been defaulted. Details are given in the
-section entitled
+application when the compiling or matching functions are called. In some cases
+the pattern can contain special leading sequences such as (*CRLF) to override
+what the application has set or what has been defaulted. Details are given in
+the section entitled
<a href="#newlineseq">"Newline sequences"</a>
-above. There are also the (*UTF8) and (*UCP) leading sequences that can be used
-to set UTF-8 and Unicode property modes; they are equivalent to setting the
-PCRE_UTF8 and the PCRE_UCP options, respectively.
+above. There are also the (*UTF8), (*UTF16), and (*UCP) leading sequences that
+can be used to set UTF and Unicode property modes; they are equivalent to
+setting the PCRE_UTF8, PCRE_UTF16, and the PCRE_UCP options, respectively.
<a name="subpattern"></a></P>
<br><a name="SEC12" href="#TOC1">SUBPATTERNS</a><br>
<P>
@@ -1289,10 +1298,14 @@ match "cataract", "erpillar" or an empty string.
<br>
2. It sets up the subpattern as a capturing subpattern. This means that, when
the whole pattern matches, that portion of the subject string that matched the
-subpattern is passed back to the caller via the <i>ovector</i> argument of
-<b>pcre_exec()</b>. Opening parentheses are counted from left to right (starting
-from 1) to obtain numbers for the capturing subpatterns. For example, if the
-string "the red king" is matched against the pattern
+subpattern is passed back to the caller via the <i>ovector</i> argument of the
+matching function. (This applies only to the traditional matching functions;
+the DFA matching functions do not support capturing.)
+</P>
+<P>
+Opening parentheses are counted from left to right (starting from 1) to obtain
+numbers for the capturing subpatterns. For example, if the string "the red
+king" is matched against the pattern
<pre>
the ((red|white) (king|queen))
</pre>
@@ -1452,7 +1465,7 @@ items:
a literal data character
the dot metacharacter
the \C escape sequence
- the \X escape sequence (in UTF-8 mode with Unicode properties)
+ the \X escape sequence
the \R escape sequence
an escape such as \d or \pL that matches a single character
a character class
@@ -1484,11 +1497,11 @@ quantifier, is taken as a literal character. For example, {,6} is not a
quantifier, but a literal string of four characters.
</P>
<P>
-In UTF-8 mode, quantifiers apply to UTF-8 characters rather than to individual
-bytes. Thus, for example, \x{100}{2} matches two UTF-8 characters, each of
-which is represented by a two-byte sequence. Similarly, when Unicode property
-support is available, \X{3} matches three Unicode extended sequences, each of
-which may be several bytes long (and they may be of different lengths).
+In UTF modes, quantifiers apply to characters rather than to individual data
+units. Thus, for example, \x{100}{2} matches two characters, each of
+which is represented by a two-byte sequence in a UTF-8 string. Similarly,
+\X{3} matches three Unicode extended sequences, each of which may be several
+data units long (and they may be of different lengths).
</P>
<P>
The quantifier {0} is permitted, causing the expression to behave as if the
@@ -1950,10 +1963,11 @@ match. If there are insufficient characters before the current position, the
assertion fails.
</P>
<P>
-In UTF-8 mode, PCRE does not allow the \C escape (which matches a single byte,
-even in UTF-8 mode) to appear in lookbehind assertions, because it makes it
-impossible to calculate the length of the lookbehind. The \X and \R escapes,
-which can match different numbers of bytes, are also not permitted.
+In a UTF mode, PCRE does not allow the \C escape (which matches a single data
+unit even in a UTF mode) to appear in lookbehind assertions, because it makes
+it impossible to calculate the length of the lookbehind. The \X and \R
+escapes, which can match different numbers of data units, are also not
+permitted.
</P>
<P>
<a href="#subpatternsassubroutines">"Subroutine"</a>
@@ -2192,7 +2206,7 @@ closing parenthesis. Nested parentheses are not permitted. If the PCRE_EXTENDED
option is set, an unescaped # character also introduces a comment, which in
this case continues to immediately after the next newline character or
character sequence in the pattern. Which characters are interpreted as newlines
-is controlled by the options passed to <b>pcre_compile()</b> or by a special
+is controlled by the options passed to a compiling function or by a special
sequence at the start of the pattern, as described in the section entitled
<a href="#newlines">"Newline conventions"</a>
above. Note that the end of this type of comment is a literal newline sequence
@@ -2491,8 +2505,9 @@ same pair of parentheses when there is a repetition.
<P>
PCRE provides a similar feature, but of course it cannot obey arbitrary Perl
code. The feature is called "callout". The caller of PCRE provides an external
-function by putting its entry point in the global variable <i>pcre_callout</i>.
-By default, this variable contains NULL, which disables all calling out.
+function by putting its entry point in the global variable <i>pcre_callout</i>
+(8-bit library) or <i>pcre16_callout</i> (16-bit library). By default, this
+variable contains NULL, which disables all calling out.
</P>
<P>
Within a regular expression, (?C) indicates the points at which the external
@@ -2502,17 +2517,17 @@ For example, this pattern has two callout points:
<pre>
(?C1)abc(?C2)def
</pre>
-If the PCRE_AUTO_CALLOUT flag is passed to <b>pcre_compile()</b>, callouts are
+If the PCRE_AUTO_CALLOUT flag is passed to a compiling function, callouts are
automatically installed before each item in the pattern. They are all numbered
255.
</P>
<P>
-During matching, when PCRE reaches a callout point (and <i>pcre_callout</i> is
-set), the external function is called. It is provided with the number of the
-callout, the position in the pattern, and, optionally, one item of data
-originally supplied by the caller of <b>pcre_exec()</b>. The callout function
-may cause matching to proceed, to backtrack, or to fail altogether. A complete
-description of the interface to the callout function is given in the
+During matching, when PCRE reaches a callout point, the external function is
+called. It is provided with the number of the callout, the position in the
+pattern, and, optionally, one item of data originally supplied by the caller of
+the matching function. The callout function may cause matching to proceed, to
+backtrack, or to fail altogether. A complete description of the interface to
+the callout function is given in the
<a href="pcrecallout.html"><b>pcrecallout</b></a>
documentation.
<a name="backtrackcontrol"></a></P>
@@ -2526,10 +2541,10 @@ remarks apply to the PCRE features described in this section.
</P>
<P>
Since these verbs are specifically related to backtracking, most of them can be
-used only when the pattern is to be matched using <b>pcre_exec()</b>, which uses
-a backtracking algorithm. With the exception of (*FAIL), which behaves like a
-failing negative assertion, they cause an error if encountered by
-<b>pcre_dfa_exec()</b>.
+used only when the pattern is to be matched using one of the traditional
+matching functions, which use a backtracking algorithm. With the exception of
+(*FAIL), which behaves like a failing negative assertion, they cause an error
+if encountered by a DFA matching function.
</P>
<P>
If any of these verbs are used in an assertion or in a subpattern that is
@@ -2613,9 +2628,8 @@ A name is always required with this verb. There may be as many instances of
</P>
<P>
When a match succeeds, the name of the last-encountered (*MARK) on the matching
-path is passed back to the caller via the <i>pcre_extra</i> data structure, as
-described in the
-<a href="pcreapi.html#extradata">section on <i>pcre_extra</i></a>
+path is passed back to the caller as described in the section entitled
+<a href="pcreapi.html#extradata">"Extra data for <b>pcre_exec()</b>"</a>
in the
<a href="pcreapi.html"><b>pcreapi</b></a>
documentation. Here is an example of <b>pcretest</b> output, where the /K
@@ -2816,7 +2830,7 @@ overrides.
<br><a name="SEC26" href="#TOC1">SEE ALSO</a><br>
<P>
<b>pcreapi</b>(3), <b>pcrecallout</b>(3), <b>pcrematching</b>(3),
-<b>pcresyntax</b>(3), <b>pcre</b>(3).
+<b>pcresyntax</b>(3), <b>pcre</b>(3), <b>pcre16(3)</b>.
</P>
<br><a name="SEC27" href="#TOC1">AUTHOR</a><br>
<P>
@@ -2829,9 +2843,9 @@ Cambridge CB2 3QH, England.
</P>
<br><a name="SEC28" href="#TOC1">REVISION</a><br>
<P>
-Last updated: 29 November 2011
+Last updated: 09 January 2012
<br>
-Copyright &copy; 1997-2011 University of Cambridge.
+Copyright &copy; 1997-2012 University of Cambridge.
<br>
<p>
Return to the <a href="index.html">PCRE index page</a>.
diff --git a/doc/html/pcreperform.html b/doc/html/pcreperform.html
index 3c60ebc..f7c8595 100644
--- a/doc/html/pcreperform.html
+++ b/doc/html/pcreperform.html
@@ -24,9 +24,9 @@ of them.
COMPILED PATTERN MEMORY USAGE
</b><br>
<P>
-Patterns are compiled by PCRE into a reasonably efficient byte code, so that
-most simple patterns do not use much memory. However, there is one case where
-the memory usage of a compiled pattern can be unexpectedly large. If a
+Patterns are compiled by PCRE into a reasonably efficient interpretive code, so
+that most simple patterns do not use much memory. However, there is one case
+where the memory usage of a compiled pattern can be unexpectedly large. If a
parenthesized subpattern has a quantifier with a minimum greater than 1 and/or
a limited maximum, the whole subpattern is repeated in the compiled code. For
example, the pattern
@@ -48,12 +48,12 @@ example, the very simple pattern
<pre>
((ab){1,1000}c){1,3}
</pre>
-uses 51K bytes when compiled. When PCRE is compiled with its default internal
-pointer size of two bytes, the size limit on a compiled pattern is 64K, and
-this is reached with the above pattern if the outer repetition is increased
-from 3 to 4. PCRE can be compiled to use larger internal pointers and thus
-handle larger compiled patterns, but it is better to try to rewrite your
-pattern to use less memory if you can.
+uses 51K bytes when compiled using the 8-bit library. When PCRE is compiled
+with its default internal pointer size of two bytes, the size limit on a
+compiled pattern is 64K data units, and this is reached with the above pattern
+if the outer repetition is increased from 3 to 4. PCRE can be compiled to use
+larger internal pointers and thus handle larger compiled patterns, but it is
+better to try to rewrite your pattern to use less memory if you can.
</P>
<P>
One way of reducing the memory usage for such patterns is to make use of PCRE's
@@ -77,11 +77,11 @@ that PCRE cannot otherwise handle.
STACK USAGE AT RUN TIME
</b><br>
<P>
-When <b>pcre_exec()</b> is used for matching, certain kinds of pattern can cause
-it to use large amounts of the process stack. In some environments the default
-process stack is quite small, and if it runs out the result is often SIGSEGV.
-This issue is probably the most frequently raised problem with PCRE. Rewriting
-your pattern can often help. The
+When <b>pcre_exec()</b> or <b>pcre16_exec()</b> is used for matching, certain
+kinds of pattern can cause it to use large amounts of the process stack. In
+some environments the default process stack is quite small, and if it runs out
+the result is often SIGSEGV. This issue is probably the most frequently raised
+problem with PCRE. Rewriting your pattern can often help. The
<a href="pcrestack.html"><b>pcrestack</b></a>
documentation discusses this issue in detail.
</P>
@@ -110,8 +110,9 @@ character classes such as [:alpha:] do not use Unicode properties, partly for
backwards compatibility, and partly for performance reasons. However, you can
set PCRE_UCP if you want Unicode character properties to be used. This can
double the matching time for items such as \d, when matched with
-<b>pcre_exec()</b>; the performance loss is less with <b>pcre_dfa_exec()</b>, and
-in both cases there is not much difference for \b.
+a traditional matching function; the performance loss is less with
+a DFA matching function, and in both cases there is not much difference for
+\b.
</P>
<P>
When a pattern begins with .* not in parentheses, or in parentheses that are
@@ -186,9 +187,9 @@ Cambridge CB2 3QH, England.
REVISION
</b><br>
<P>
-Last updated: 16 May 2010
+Last updated: 09 January 2012
<br>
-Copyright &copy; 1997-2010 University of Cambridge.
+Copyright &copy; 1997-2012 University of Cambridge.
<br>
<p>
Return to the <a href="index.html">PCRE index page</a>.
diff --git a/doc/html/pcreposix.html b/doc/html/pcreposix.html
index 6bd4b96..637305d 100644
--- a/doc/html/pcreposix.html
+++ b/doc/html/pcreposix.html
@@ -44,11 +44,12 @@ man page, in case the conversion went wrong.
</P>
<br><a name="SEC2" href="#TOC1">DESCRIPTION</a><br>
<P>
-This set of functions provides a POSIX-style API to the PCRE regular expression
-package. See the
+This set of functions provides a POSIX-style API for the PCRE regular
+expression 8-bit library. See the
<a href="pcreapi.html"><b>pcreapi</b></a>
documentation for a description of PCRE's native API, which contains much
-additional functionality.
+additional functionality. There is no POSIX-style wrapper for PCRE's 16-bit
+library.
</P>
<P>
The functions described here are just wrapper functions that ultimately call
@@ -282,9 +283,9 @@ Cambridge CB2 3QH, England.
</P>
<br><a name="SEC9" href="#TOC1">REVISION</a><br>
<P>
-Last updated: 16 May 2010
+Last updated: 09 January 2012
<br>
-Copyright &copy; 1997-2010 University of Cambridge.
+Copyright &copy; 1997-2012 University of Cambridge.
<br>
<p>
Return to the <a href="index.html">PCRE index page</a>.
diff --git a/doc/html/pcreprecompile.html b/doc/html/pcreprecompile.html
index 8b3e0bc..cbc2812 100644
--- a/doc/html/pcreprecompile.html
+++ b/doc/html/pcreprecompile.html
@@ -29,26 +29,30 @@ If you are not using any private character tables (see the
<a href="pcre_maketables.html"><b>pcre_maketables()</b></a>
documentation), this is relatively straightforward. If you are using private
tables, it is a little bit more complicated. However, if you are using the
-just-in-time optimization feature of <b>pcre_study()</b>, it is not possible to
-save and reload the JIT data.
+just-in-time optimization feature, it is not possible to save and reload the
+JIT data.
</P>
<P>
If you save compiled patterns to a file, you can copy them to a different host
-and run them there. This works even if the new host has the opposite endianness
-to the one on which the patterns were compiled. There may be a small
-performance penalty, but it should be insignificant. However, compiling regular
-expressions with one version of PCRE for use with a different version is not
-guaranteed to work and may cause crashes, and saving and restoring a compiled
-pattern loses any JIT optimization data.
+and run them there. If the two hosts have different endianness (byte order),
+you should run the <b>pcre[16]_pattern_to_host_byte_order()</b> function on the
+new host before trying to match the pattern. The matching functions return
+PCRE_ERROR_BADENDIANNESS if they detect a pattern with the wrong endianness.
+</P>
+<P>
+Compiling regular expressions with one version of PCRE for use with a different
+version is not guaranteed to work and may cause crashes, and saving and
+restoring a compiled pattern loses any JIT optimization data.
</P>
<br><a name="SEC2" href="#TOC1">SAVING A COMPILED PATTERN</a><br>
<P>
-The value returned by <b>pcre_compile()</b> points to a single block of memory
-that holds the compiled pattern and associated data. You can find the length of
-this block in bytes by calling <b>pcre_fullinfo()</b> with an argument of
-PCRE_INFO_SIZE. You can then save the data in any appropriate manner. Here is
-sample code that compiles a pattern and writes it to a file. It assumes that
-the variable <i>fd</i> refers to a file that is open for output:
+The value returned by <b>pcre[16]_compile()</b> points to a single block of
+memory that holds the compiled pattern and associated data. You can find the
+length of this block in bytes by calling <b>pcre[16]_fullinfo()</b> with an
+argument of PCRE_INFO_SIZE. You can then save the data in any appropriate
+manner. Here is sample code for the 8-bit library that compiles a pattern and
+writes it to a file. It assumes that the variable <i>fd</i> refers to a file
+that is open for output:
<pre>
int erroroffset, rc, size;
char *error;
@@ -83,31 +87,32 @@ If the pattern has been studied, it is also possible to save the normal study
data in a similar way to the compiled pattern itself. However, if the
PCRE_STUDY_JIT_COMPILE was used, the just-in-time data that is created cannot
be saved because it is too dependent on the current environment. When studying
-generates additional information, <b>pcre_study()</b> returns a pointer to a
-<b>pcre_extra</b> data block. Its format is defined in the
+generates additional information, <b>pcre[16]_study()</b> returns a pointer to a
+<b>pcre[16]_extra</b> data block. Its format is defined in the
<a href="pcreapi.html#extradata">section on matching a pattern</a>
in the
<a href="pcreapi.html"><b>pcreapi</b></a>
documentation. The <i>study_data</i> field points to the binary study data, and
-this is what you must save (not the <b>pcre_extra</b> block itself). The length
-of the study data can be obtained by calling <b>pcre_fullinfo()</b> with an
-argument of PCRE_INFO_STUDYSIZE. Remember to check that <b>pcre_study()</b> did
-return a non-NULL value before trying to save the study data.
+this is what you must save (not the <b>pcre[16]_extra</b> block itself). The
+length of the study data can be obtained by calling <b>pcre[16]_fullinfo()</b>
+with an argument of PCRE_INFO_STUDYSIZE. Remember to check that
+<b>pcre[16]_study()</b> did return a non-NULL value before trying to save the
+study data.
</P>
<br><a name="SEC3" href="#TOC1">RE-USING A PRECOMPILED PATTERN</a><br>
<P>
Re-using a precompiled pattern is straightforward. Having reloaded it into main
-memory, you pass its pointer to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b> in
-the usual way. This should work even on another host, and even if that host has
-the opposite endianness to the one where the pattern was compiled.
+memory, called <b>pcre[16]_pattern_to_host_byte_order()</b> if necessary,
+you pass its pointer to <b>pcre[16]_exec()</b> or <b>pcre[16]_dfa_exec()</b> in
+the usual way.
</P>
<P>
However, if you passed a pointer to custom character tables when the pattern
-was compiled (the <i>tableptr</i> argument of <b>pcre_compile()</b>), you must
-now pass a similar pointer to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>,
-because the value saved with the compiled pattern will obviously be nonsense. A
-field in a <b>pcre_extra()</b> block is used to pass this data, as described in
-the
+was compiled (the <i>tableptr</i> argument of <b>pcre[16]_compile()</b>), you
+must now pass a similar pointer to <b>pcre[16]_exec()</b> or
+<b>pcre[16]_dfa_exec()</b>, because the value saved with the compiled pattern
+will obviously be nonsense. A field in a <b>pcre[16]_extra()</b> block is used
+to pass this data, as described in the
<a href="pcreapi.html#extradata">section on matching a pattern</a>
in the
<a href="pcreapi.html"><b>pcreapi</b></a>
@@ -115,18 +120,18 @@ documentation.
</P>
<P>
If you did not provide custom character tables when the pattern was compiled,
-the pointer in the compiled pattern is NULL, which causes <b>pcre_exec()</b> to
-use PCRE's internal tables. Thus, you do not need to take any special action at
-run time in this case.
+the pointer in the compiled pattern is NULL, which causes the matching
+functions to use PCRE's internal tables. Thus, you do not need to take any
+special action at run time in this case.
</P>
<P>
If you saved study data with the compiled pattern, you need to create your own
-<b>pcre_extra</b> data block and set the <i>study_data</i> field to point to the
+<b>pcre[16]_extra</b> data block and set the <i>study_data</i> field to point to the
reloaded study data. You must also set the PCRE_EXTRA_STUDY_DATA bit in the
<i>flags</i> field to indicate that study data is present. Then pass the
-<b>pcre_extra</b> block to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b> in the
-usual way. If the pattern was studied for just-in-time optimization, that data
-cannot be saved, and so is lost by a save/restore cycle.
+<b>pcre[16]_extra</b> block to the matching function in the usual way. If the
+pattern was studied for just-in-time optimization, that data cannot be saved,
+and so is lost by a save/restore cycle.
</P>
<br><a name="SEC4" href="#TOC1">COMPATIBILITY WITH DIFFERENT PCRE RELEASES</a><br>
<P>
@@ -144,9 +149,9 @@ Cambridge CB2 3QH, England.
</P>
<br><a name="SEC6" href="#TOC1">REVISION</a><br>
<P>
-Last updated: 26 August 2011
+Last updated: 10 January 2012
<br>
-Copyright &copy; 1997-2011 University of Cambridge.
+Copyright &copy; 1997-2012 University of Cambridge.
<br>
<p>
Return to the <a href="index.html">PCRE index page</a>.
diff --git a/doc/html/pcresample.html b/doc/html/pcresample.html
index dcd69bf..aca9184 100644
--- a/doc/html/pcresample.html
+++ b/doc/html/pcresample.html
@@ -24,11 +24,12 @@ documentation. If you do not have a copy of the PCRE distribution, you can save
this listing to re-create <i>pcredemo.c</i>.
</P>
<P>
-The program compiles the regular expression that is its first argument, and
-matches it against the subject string in its second argument. No PCRE options
-are set, and default character tables are used. If matching succeeds, the
-program outputs the portion of the subject that matched, together with the
-contents of any captured substrings.
+The demonstration program, which uses the original PCRE 8-bit library, compiles
+the regular expression that is its first argument, and matches it against the
+subject string in its second argument. No PCRE options are set, and default
+character tables are used. If matching succeeds, the program outputs the
+portion of the subject that matched, together with the contents of any captured
+substrings.
</P>
<P>
If the -g option is given on the command line, the program then goes on to
@@ -65,8 +66,8 @@ tests like this:
</pre>
Note that there is a much more comprehensive test program, called
<a href="pcretest.html"><b>pcretest</b>,</a>
-which supports many more facilities for testing regular expressions and the
-PCRE library. The
+which supports many more facilities for testing regular expressions and both
+PCRE libraries. The
<a href="pcredemo.html"><b>pcredemo</b></a>
program is provided as a simple coding example.
</P>
@@ -100,9 +101,9 @@ Cambridge CB2 3QH, England.
REVISION
</b><br>
<P>
-Last updated: 17 November 2010
+Last updated: 10 January 2012
<br>
-Copyright &copy; 1997-2010 University of Cambridge.
+Copyright &copy; 1997-2012 University of Cambridge.
<br>
<p>
Return to the <a href="index.html">PCRE index page</a>.
diff --git a/doc/html/pcrestack.html b/doc/html/pcrestack.html
index 78484de..8bf8c92 100644
--- a/doc/html/pcrestack.html
+++ b/doc/html/pcrestack.html
@@ -16,11 +16,11 @@ man page, in case the conversion went wrong.
PCRE DISCUSSION OF STACK USAGE
</b><br>
<P>
-When you call <b>pcre_exec()</b>, it makes use of an internal function called
-<b>match()</b>. This calls itself recursively at branch points in the pattern,
-in order to remember the state of the match so that it can back up and try a
-different alternative if the first one fails. As matching proceeds deeper and
-deeper into the tree of possibilities, the recursion depth increases. The
+When you call <b>pcre[16]_exec()</b>, it makes use of an internal function
+called <b>match()</b>. This calls itself recursively at branch points in the
+pattern, in order to remember the state of the match so that it can back up and
+try a different alternative if the first one fails. As matching proceeds deeper
+and deeper into the tree of possibilities, the recursion depth increases. The
<b>match()</b> function is also called in other circumstances, for example,
whenever a parenthesized sub-pattern is entered, and in certain cases of
repetition.
@@ -33,32 +33,32 @@ the recursive call would immediately be passed back as the result of the
current call (a "tail recursion"), the function is just restarted instead.
</P>
<P>
-The above comments apply when <b>pcre_exec()</b> is run in its normal
+The above comments apply when <b>pcre[16]_exec()</b> is run in its normal
interpretive manner. If the pattern was studied with the
PCRE_STUDY_JIT_COMPILE option, and just-in-time compiling was successful, and
-the options passed to <b>pcre_exec()</b> were not incompatible, the matching
+the options passed to <b>pcre[16]_exec()</b> were not incompatible, the matching
process uses the JIT-compiled code instead of the <b>match()</b> function. In
this case, the memory requirements are handled entirely differently. See the
<a href="pcrejit.html"><b>pcrejit</b></a>
documentation for details.
</P>
<P>
-The <b>pcre_dfa_exec()</b> function operates in an entirely different way, and
-uses recursion only when there is a regular expression recursion or subroutine
-call in the pattern. This includes the processing of assertion and "once-only"
-subpatterns, which are handled like subroutine calls. Normally, these are never
-very deep, and the limit on the complexity of <b>pcre_dfa_exec()</b> is
-controlled by the amount of workspace it is given. However, it is possible to
-write patterns with runaway infinite recursions; such patterns will cause
-<b>pcre_dfa_exec()</b> to run out of stack. At present, there is no protection
-against this.
+The <b>pcre[16]_dfa_exec()</b> function operates in an entirely different way,
+and uses recursion only when there is a regular expression recursion or
+subroutine call in the pattern. This includes the processing of assertion and
+"once-only" subpatterns, which are handled like subroutine calls. Normally,
+these are never very deep, and the limit on the complexity of
+<b>pcre[16]_dfa_exec()</b> is controlled by the amount of workspace it is given.
+However, it is possible to write patterns with runaway infinite recursions;
+such patterns will cause <b>pcre[16]_dfa_exec()</b> to run out of stack. At
+present, there is no protection against this.
</P>
<P>
-The comments that follow do NOT apply to <b>pcre_dfa_exec()</b>; they are
-relevant only for <b>pcre_exec()</b> without the JIT optimization.
+The comments that follow do NOT apply to <b>pcre[16]_dfa_exec()</b>; they are
+relevant only for <b>pcre[16]_exec()</b> without the JIT optimization.
</P>
<br><b>
-Reducing <b>pcre_exec()</b>'s stack usage
+Reducing <b>pcre[16]_exec()</b>'s stack usage
</b><br>
<P>
Each time that <b>match()</b> is actually called recursively, it uses memory
@@ -94,35 +94,36 @@ subject strings is to write repeated parenthesized subpatterns to match more
than one character whenever possible.
</P>
<br><b>
-Compiling PCRE to use heap instead of stack for <b>pcre_exec()</b>
+Compiling PCRE to use heap instead of stack for <b>pcre[16]_exec()</b>
</b><br>
<P>
In environments where stack memory is constrained, you might want to compile
PCRE to use heap memory instead of stack for remembering back-up points when
-<b>pcre_exec()</b> is running. This makes it run a lot more slowly, however.
+<b>pcre[16]_exec()</b> is running. This makes it run a lot more slowly, however.
Details of how to do this are given in the
<a href="pcrebuild.html"><b>pcrebuild</b></a>
documentation. When built in this way, instead of using the stack, PCRE obtains
and frees memory by calling the functions that are pointed to by the
-<b>pcre_stack_malloc</b> and <b>pcre_stack_free</b> variables. By default, these
-point to <b>malloc()</b> and <b>free()</b>, but you can replace the pointers to
-cause PCRE to use your own functions. Since the block sizes are always the
-same, and are always freed in reverse order, it may be possible to implement
-customized memory handlers that are more efficient than the standard functions.
+<b>pcre[16]_stack_malloc</b> and <b>pcre[16]_stack_free</b> variables. By
+default, these point to <b>malloc()</b> and <b>free()</b>, but you can replace
+the pointers to cause PCRE to use your own functions. Since the block sizes are
+always the same, and are always freed in reverse order, it may be possible to
+implement customized memory handlers that are more efficient than the standard
+functions.
</P>
<br><b>
-Limiting <b>pcre_exec()</b>'s stack usage
+Limiting <b>pcre[16]_exec()</b>'s stack usage
</b><br>
<P>
You can set limits on the number of times that <b>match()</b> is called, both in
-total and recursively. If a limit is exceeded, <b>pcre_exec()</b> returns an
+total and recursively. If a limit is exceeded, <b>pcre[16]_exec()</b> returns an
error code. Setting suitable limits should prevent it from running out of
stack. The default values of the limits are very large, and unlikely ever to
operate. They can be changed when PCRE is built, and they can also be set when
-<b>pcre_exec()</b> is called. For details of these interfaces, see the
+<b>pcre[16]_exec()</b> is called. For details of these interfaces, see the
<a href="pcrebuild.html"><b>pcrebuild</b></a>
documentation and the
-<a href="pcreapi.html#extradata">section on extra data for <b>pcre_exec()</b></a>
+<a href="pcreapi.html#extradata">section on extra data for <b>pcre[16]_exec()</b></a>
in the
<a href="pcreapi.html"><b>pcreapi</b></a>
documentation.
@@ -138,7 +139,7 @@ In Unix-like environments, the <b>pcretest</b> test program has a command line
option (<b>-S</b>) that can be used to increase the size of its stack. As long
as the stack is large enough, another option (<b>-M</b>) can be used to find the
smallest limits that allow a particular pattern to match a given subject
-string. This is done by calling <b>pcre_exec()</b> repeatedly with different
+string. This is done by calling <b>pcre[16]_exec()</b> repeatedly with different
limits.
</P>
<br><b>
@@ -163,7 +164,7 @@ limit on stack size by code such as this:
</pre>
This reads the current limits (soft and hard) using <b>getrlimit()</b>, then
attempts to increase the soft limit to 100Mb using <b>setrlimit()</b>. You must
-do this before calling <b>pcre_exec()</b>.
+do this before calling <b>pcre[16]_exec()</b>.
</P>
<br><b>
Changing stack size in Mac OS X
@@ -189,9 +190,9 @@ Cambridge CB2 3QH, England.
REVISION
</b><br>
<P>
-Last updated: 26 August 2011
+Last updated: 10 January 2012
<br>
-Copyright &copy; 1997-2011 University of Cambridge.
+Copyright &copy; 1997-2012 University of Cambridge.
<br>
<p>
Return to the <a href="index.html">PCRE index page</a>.
diff --git a/doc/html/pcresyntax.html b/doc/html/pcresyntax.html
index 9fa3ebd..0e7d364 100644
--- a/doc/html/pcresyntax.html
+++ b/doc/html/pcresyntax.html
@@ -46,8 +46,7 @@ man page, in case the conversion went wrong.
The full syntax and semantics of the regular expressions that are supported by
PCRE are described in the
<a href="pcrepattern.html"><b>pcrepattern</b></a>
-documentation. This document contains just a quick-reference summary of the
-syntax.
+documentation. This document contains a quick-reference summary of the syntax.
</P>
<br><a name="SEC2" href="#TOC1">QUOTING</a><br>
<P>
@@ -76,7 +75,7 @@ syntax.
<pre>
. any character except newline;
in dotall mode, any character whatsoever
- \C one byte, even in UTF-8 mode (best avoided)
+ \C one data unit, even in UTF mode (best avoided)
\d a decimal digit
\D a character that is not a decimal digit
\h a horizontal whitespace character
@@ -94,7 +93,7 @@ syntax.
\X an extended Unicode sequence
</pre>
In PCRE, by default, \d, \D, \s, \S, \w, and \W recognize only ASCII
-characters, even in UTF-8 mode. However, this can be changed by setting the
+characters, even in a UTF mode. However, this can be changed by setting the
PCRE_UCP option.
</P>
<br><a name="SEC5" href="#TOC1">GENERAL CATEGORY PROPERTIES FOR \p and \P</a><br>
@@ -367,7 +366,8 @@ The following are recognized only at the start of a pattern or after one of the
newline-setting options with similar syntax:
<pre>
(*NO_START_OPT) no start-match optimization (PCRE_NO_START_OPTIMIZE)
- (*UTF8) set UTF-8 mode (PCRE_UTF8)
+ (*UTF8) set UTF-8 mode: 8-bit library (PCRE_UTF8)
+ (*UTF16) set UTF-16 mode: 16-bit library (PCRE_UTF16)
(*UCP) set PCRE_UCP (use Unicode properties for \d etc)
</PRE>
</P>
@@ -439,6 +439,7 @@ The following act immediately they are reached:
<pre>
(*ACCEPT) force successful match
(*FAIL) force backtrack; synonym (*F)
+ (*MARK:NAME) set name to be passed back; synonym (*:NAME)
</pre>
The following act only when a subsequent match failure causes a backtrack to
reach them. They all force a match failure, but they differ in what happens
@@ -447,14 +448,18 @@ pattern is not anchored.
<pre>
(*COMMIT) overall failure, no advance of starting point
(*PRUNE) advance to next starting character
- (*SKIP) advance start to current matching position
+ (*PRUNE:NAME) equivalent to (*MARK:NAME)(*PRUNE)
+ (*SKIP) advance to current matching position
+ (*SKIP:NAME) advance to position corresponding to an earlier
+ (*MARK:NAME); if not found, the (*SKIP) is ignored
(*THEN) local failure, backtrack to next alternation
+ (*THEN:NAME) equivalent to (*MARK:NAME)(*THEN)
</PRE>
</P>
<br><a name="SEC22" href="#TOC1">NEWLINE CONVENTIONS</a><br>
<P>
These are recognized only at the very start of the pattern or after a
-(*BSR_...) or (*UTF8) or (*UCP) option.
+(*BSR_...), (*UTF8), (*UTF16) or (*UCP) option.
<pre>
(*CR) carriage return only
(*LF) linefeed only
@@ -466,7 +471,7 @@ These are recognized only at the very start of the pattern or after a
<br><a name="SEC23" href="#TOC1">WHAT \R MATCHES</a><br>
<P>
These are recognized only at the very start of the pattern or after a
-(*...) option that sets the newline convention or UTF-8 or UCP mode.
+(*...) option that sets the newline convention or a UTF or UCP mode.
<pre>
(*BSR_ANYCRLF) CR, LF, or CRLF
(*BSR_UNICODE) any Unicode newline sequence
@@ -495,9 +500,9 @@ Cambridge CB2 3QH, England.
</P>
<br><a name="SEC27" href="#TOC1">REVISION</a><br>
<P>
-Last updated: 21 November 2010
+Last updated: 10 January 2012
<br>
-Copyright &copy; 1997-2010 University of Cambridge.
+Copyright &copy; 1997-2012 University of Cambridge.
<br>
<p>
Return to the <a href="index.html">PCRE index page</a>.
diff --git a/doc/html/pcretest.html b/doc/html/pcretest.html
index c883064..454a099 100644
--- a/doc/html/pcretest.html
+++ b/doc/html/pcretest.html
@@ -14,20 +14,21 @@ man page, in case the conversion went wrong.
<br>
<ul>
<li><a name="TOC1" href="#SEC1">SYNOPSIS</a>
-<li><a name="TOC2" href="#SEC2">COMMAND LINE OPTIONS</a>
-<li><a name="TOC3" href="#SEC3">DESCRIPTION</a>
-<li><a name="TOC4" href="#SEC4">PATTERN MODIFIERS</a>
-<li><a name="TOC5" href="#SEC5">DATA LINES</a>
-<li><a name="TOC6" href="#SEC6">THE ALTERNATIVE MATCHING FUNCTION</a>
-<li><a name="TOC7" href="#SEC7">DEFAULT OUTPUT FROM PCRETEST</a>
-<li><a name="TOC8" href="#SEC8">OUTPUT FROM THE ALTERNATIVE MATCHING FUNCTION</a>
-<li><a name="TOC9" href="#SEC9">RESTARTING AFTER A PARTIAL MATCH</a>
-<li><a name="TOC10" href="#SEC10">CALLOUTS</a>
-<li><a name="TOC11" href="#SEC11">NON-PRINTING CHARACTERS</a>
-<li><a name="TOC12" href="#SEC12">SAVING AND RELOADING COMPILED PATTERNS</a>
-<li><a name="TOC13" href="#SEC13">SEE ALSO</a>
-<li><a name="TOC14" href="#SEC14">AUTHOR</a>
-<li><a name="TOC15" href="#SEC15">REVISION</a>
+<li><a name="TOC2" href="#SEC2">PCRE's 8-BIT and 16-BIT LIBRARIES</a>
+<li><a name="TOC3" href="#SEC3">COMMAND LINE OPTIONS</a>
+<li><a name="TOC4" href="#SEC4">DESCRIPTION</a>
+<li><a name="TOC5" href="#SEC5">PATTERN MODIFIERS</a>
+<li><a name="TOC6" href="#SEC6">DATA LINES</a>
+<li><a name="TOC7" href="#SEC7">THE ALTERNATIVE MATCHING FUNCTION</a>
+<li><a name="TOC8" href="#SEC8">DEFAULT OUTPUT FROM PCRETEST</a>
+<li><a name="TOC9" href="#SEC9">OUTPUT FROM THE ALTERNATIVE MATCHING FUNCTION</a>
+<li><a name="TOC10" href="#SEC10">RESTARTING AFTER A PARTIAL MATCH</a>
+<li><a name="TOC11" href="#SEC11">CALLOUTS</a>
+<li><a name="TOC12" href="#SEC12">NON-PRINTING CHARACTERS</a>
+<li><a name="TOC13" href="#SEC13">SAVING AND RELOADING COMPILED PATTERNS</a>
+<li><a name="TOC14" href="#SEC14">SEE ALSO</a>
+<li><a name="TOC15" href="#SEC15">AUTHOR</a>
+<li><a name="TOC16" href="#SEC16">REVISION</a>
</ul>
<br><a name="SEC1" href="#TOC1">SYNOPSIS</a><br>
<P>
@@ -42,12 +43,37 @@ details of the regular expressions themselves, see the
documentation. For details of the PCRE library function calls and their
options, see the
<a href="pcreapi.html"><b>pcreapi</b></a>
+and
+<a href="pcre16.html"><b>pcre16</b></a>
documentation. The input for <b>pcretest</b> is a sequence of regular expression
patterns and strings to be matched, as described below. The output shows the
result of each match. Options on the command line and the patterns control PCRE
options and exactly what is output.
</P>
-<br><a name="SEC2" href="#TOC1">COMMAND LINE OPTIONS</a><br>
+<br><a name="SEC2" href="#TOC1">PCRE's 8-BIT and 16-BIT LIBRARIES</a><br>
+<P>
+From release 8.30, two separate PCRE libraries can be built. The original one
+supports 8-bit character strings, whereas the newer 16-bit library supports
+character strings encoded in 16-bit units. The <b>pcretest</b> program can be
+used to test both libraries. However, it is itself still an 8-bit program,
+reading 8-bit input and writing 8-bit output. When testing the 16-bit library,
+the patterns and data strings are converted to 16-bit format before being
+passed to the PCRE library functions. Results are converted to 8-bit for
+output.
+</P>
+<P>
+References to functions and structures of the form <b>pcre[16]_xx</b> below
+mean "<b>pcre_xx</b> when using the 8-bit library or <b>pcre16_xx</b> when using
+the 16-bit library".
+</P>
+<br><a name="SEC3" href="#TOC1">COMMAND LINE OPTIONS</a><br>
+<P>
+<b>-16</b>
+If both the 8-bit and the 16-bit libraries have been built, this option causes
+the 16-bit library to be used. If only the 16-bit library has been built, this
+is the default (so has no effect). If only the 8-bit library has been built,
+this option causes an error.
+</P>
<P>
<b>-b</b>
Behave as if each pattern has the <b>/B</b> (show byte code) modifier; the
@@ -56,7 +82,27 @@ internal form is output after compilation.
<P>
<b>-C</b>
Output the version number of the PCRE library, and all available information
-about the optional features that are included, and then exit.
+about the optional features that are included, and then exit. All other options
+are ignored.
+</P>
+<P>
+<b>-C</b> <i>option</i>
+Output information about a specific build-time option, then exit. This
+functionality is intended for use in scripts such as <b>RunTest</b>. The
+following options output the value indicated:
+<pre>
+ linksize the internal link size (2, 3, or 4)
+ newline the default newline setting:
+ CR, LF, CRLF, ANYCRLF, or ANY
+</pre>
+The following options output 1 for true or zero for false:
+<pre>
+ jit just-in-time support is available
+ pcre16 the 16-bit library was built
+ pcre8 the 8-bit library was built
+ ucp Unicode property support is available
+ utf UTF-8 and/or UTF-16 support is available
+</PRE>
</P>
<P>
<b>-d</b>
@@ -67,8 +113,8 @@ form and information about the compiled pattern is output after compilation;
<P>
<b>-dfa</b>
Behave as if each data line contains the \D escape sequence; this causes the
-alternative matching function, <b>pcre_dfa_exec()</b>, to be used instead of the
-standard <b>pcre_exec()</b> function (more detail is given below).
+alternative matching function, <b>pcre[16]_dfa_exec()</b>, to be used instead of
+the standard <b>pcre[16]_exec()</b> function (more detail is given below).
</P>
<P>
<b>-help</b>
@@ -83,27 +129,28 @@ compiled pattern is given after compilation.
<b>-M</b>
Behave as if each data line contains the \M escape sequence; this causes
PCRE to discover the minimum MATCH_LIMIT and MATCH_LIMIT_RECURSION settings by
-calling <b>pcre_exec()</b> repeatedly with different limits.
+calling <b>pcre[16]_exec()</b> repeatedly with different limits.
</P>
<P>
<b>-m</b>
Output the size of each compiled pattern after it has been compiled. This is
-equivalent to adding <b>/M</b> to each regular expression.
+equivalent to adding <b>/M</b> to each regular expression. The size is given in
+bytes for both libraries.
</P>
<P>
<b>-o</b> <i>osize</i>
Set the number of elements in the output vector that is used when calling
-<b>pcre_exec()</b> or <b>pcre_dfa_exec()</b> to be <i>osize</i>. The default value
-is 45, which is enough for 14 capturing subexpressions for <b>pcre_exec()</b> or
-22 different matches for <b>pcre_dfa_exec()</b>. The vector size can be
-changed for individual matching calls by including \O in the data line (see
-below).
+<b>pcre[16]_exec()</b> or <b>pcre[16]_dfa_exec()</b> to be <i>osize</i>. The
+default value is 45, which is enough for 14 capturing subexpressions for
+<b>pcre[16]_exec()</b> or 22 different matches for <b>pcre[16]_dfa_exec()</b>.
+The vector size can be changed for individual matching calls by including \O
+in the data line (see below).
</P>
<P>
<b>-p</b>
Behave as if each pattern has the <b>/P</b> modifier; the POSIX wrapper API is
used to call PCRE. None of the other options has any effect when <b>-p</b> is
-set.
+set. This option can be used only with the 8-bit library.
</P>
<P>
<b>-q</b>
@@ -118,22 +165,24 @@ megabytes.
<b>-s</b> or <b>-s+</b>
Behave as if each pattern has the <b>/S</b> modifier; in other words, force each
pattern to be studied. If <b>-s+</b> is used, the PCRE_STUDY_JIT_COMPILE flag is
-passed to <b>pcre_study()</b>, causing just-in-time optimization to be set up if
-it is available. If the <b>/I</b> or <b>/D</b> option is present on a pattern
-(requesting output about the compiled pattern), information about the result of
-studying is not included when studying is caused only by <b>-s</b> and neither
-<b>-i</b> nor <b>-d</b> is present on the command line. This behaviour means that
-the output from tests that are run with and without <b>-s</b> should be
-identical, except when options that output information about the actual running
-of a match are set. The <b>-M</b>, <b>-t</b>, and <b>-tm</b> options, which give
-information about resources used, are likely to produce different output with
-and without <b>-s</b>. Output may also differ if the <b>/C</b> option is present
-on an individual pattern. This uses callouts to trace the the matching process,
-and this may be different between studied and non-studied patterns. If the
-pattern contains (*MARK) items there may also be differences, for the same
-reason. The <b>-s</b> command line option can be overridden for specific
-patterns that should never be studied (see the <b>/S</b> pattern modifier
-below).
+passed to <b>pcre[16]_study()</b>, causing just-in-time optimization to be set
+up if it is available. If the <b>/I</b> or <b>/D</b> option is present on a
+pattern (requesting output about the compiled pattern), information about the
+result of studying is not included when studying is caused only by <b>-s</b> and
+neither <b>-i</b> nor <b>-d</b> is present on the command line. This behaviour
+means that the output from tests that are run with and without <b>-s</b> should
+be identical, except when options that output information about the actual
+running of a match are set.
+<br>
+<br>
+The <b>-M</b>, <b>-t</b>, and <b>-tm</b> options, which give information about
+resources used, are likely to produce different output with and without
+<b>-s</b>. Output may also differ if the <b>/C</b> option is present on an
+individual pattern. This uses callouts to trace the the matching process, and
+this may be different between studied and non-studied patterns. If the pattern
+contains (*MARK) items there may also be differences, for the same reason. The
+<b>-s</b> command line option can be overridden for specific patterns that
+should never be studied (see the <b>/S</b> pattern modifier below).
</P>
<P>
<b>-t</b>
@@ -150,7 +199,7 @@ to iterate 500000 times.
This is like <b>-t</b> except that it times only the matching phase, not the
compile or study phases.
</P>
-<br><a name="SEC3" href="#TOC1">DESCRIPTION</a><br>
+<br><a name="SEC4" href="#TOC1">DESCRIPTION</a><br>
<P>
If <b>pcretest</b> is given two filename arguments, it reads from the first and
writes to the second. If it is given only one filename argument, it reads from
@@ -207,7 +256,7 @@ backslash, because
is interpreted as the first line of a pattern that starts with "abc/", causing
pcretest to read the next line as a continuation of the regular expression.
</P>
-<br><a name="SEC4" href="#TOC1">PATTERN MODIFIERS</a><br>
+<br><a name="SEC5" href="#TOC1">PATTERN MODIFIERS</a><br>
<P>
A pattern may be followed by any number of modifiers, which are mostly single
characters. Following Perl usage, these are referred to below as, for example,
@@ -219,7 +268,7 @@ the modifiers themselves.
<P>
The <b>/i</b>, <b>/m</b>, <b>/s</b>, and <b>/x</b> modifiers set the PCRE_CASELESS,
PCRE_MULTILINE, PCRE_DOTALL, or PCRE_EXTENDED options, respectively, when
-<b>pcre_compile()</b> is called. These four modifier letters have the same
+<b>pcre[16]_compile()</b> is called. These four modifier letters have the same
effect as they do in Perl. For example:
<pre>
/caseless/i
@@ -227,8 +276,12 @@ effect as they do in Perl. For example:
The following table shows additional modifiers for setting PCRE compile-time
options that do not correspond to anything in Perl:
<pre>
- <b>/8</b> PCRE_UTF8
- <b>/?</b> PCRE_NO_UTF8_CHECK
+ <b>/8</b> PCRE_UTF8 ) when using the 8-bit
+ <b>/?</b> PCRE_NO_UTF8_CHECK ) library
+
+ <b>/8</b> PCRE_UTF16 ) when using the 16-bit
+ <b>/?</b> PCRE_NO_UTF16_CHECK ) library
+
<b>/A</b> PCRE_ANCHORED
<b>/C</b> PCRE_AUTO_CALLOUT
<b>/E</b> PCRE_DOLLAR_ENDONLY
@@ -254,10 +307,13 @@ This example sets multiline matching with CRLF as the line ending sequence:
<pre>
/^abc/m&#60;CRLF&#62;
</pre>
-As well as turning on the PCRE_UTF8 option, the <b>/8</b> modifier also causes
-any non-printing characters in output strings to be printed using the
-\x{hh...} notation if they are valid UTF-8 sequences. Full details of the PCRE
-options are given in the
+As well as turning on the PCRE_UTF8/16 option, the <b>/8</b> modifier causes
+all non-printing characters in output strings to be printed using the
+\x{hh...} notation. Otherwise, those less than 0x100 are output in hex without
+the curly brackets.
+</P>
+<P>
+Full details of the PCRE options are given in the
<a href="pcreapi.html"><b>pcreapi</b></a>
documentation.
</P>
@@ -269,14 +325,14 @@ Searching for all possible matches within each subject string can be requested
by the <b>/g</b> or <b>/G</b> modifier. After finding a match, PCRE is called
again to search the remainder of the subject string. The difference between
<b>/g</b> and <b>/G</b> is that the former uses the <i>startoffset</i> argument to
-<b>pcre_exec()</b> to start searching at a new point within the entire string
-(which is in effect what Perl does), whereas the latter passes over a shortened
-substring. This makes a difference to the matching process if the pattern
-begins with a lookbehind assertion (including \b or \B).
+<b>pcre[16]_exec()</b> to start searching at a new point within the entire
+string (which is in effect what Perl does), whereas the latter passes over a
+shortened substring. This makes a difference to the matching process if the
+pattern begins with a lookbehind assertion (including \b or \B).
</P>
<P>
-If any call to <b>pcre_exec()</b> in a <b>/g</b> or <b>/G</b> sequence matches an
-empty string, the next call is done with the PCRE_NOTEMPTY_ATSTART and
+If any call to <b>pcre[16]_exec()</b> in a <b>/g</b> or <b>/G</b> sequence matches
+an empty string, the next call is done with the PCRE_NOTEMPTY_ATSTART and
PCRE_ANCHORED flags set in order to search for another, non-empty, match at the
same point. If this second match fails, the start offset is advanced, and the
normal match is retried. This imitates the way Perl handles such cases when
@@ -304,20 +360,19 @@ modifier because /S+ has another meaning.
</P>
<P>
The <b>/=</b> modifier requests that the values of all potential captured
-parentheses be output after a match by <b>pcre_exec()</b>. By default, only
-those up to the highest one actually used in the match are output
-(corresponding to the return code from <b>pcre_exec()</b>). Values in the
-offsets vector corresponding to higher numbers should be set to -1, and these
-are output as "&#60;unset&#62;". This modifier gives a way of checking that this is
-happening.
+parentheses be output after a match. By default, only those up to the highest
+one actually used in the match are output (corresponding to the return code
+from <b>pcre[16]_exec()</b>). Values in the offsets vector corresponding to
+higher numbers should be set to -1, and these are output as "&#60;unset&#62;". This
+modifier gives a way of checking that this is happening.
</P>
<P>
The <b>/B</b> modifier is a debugging feature. It requests that <b>pcretest</b>
-output a representation of the compiled byte code after compilation. Normally
-this information contains length and offset values; however, if <b>/Z</b> is
-also present, this data is replaced by spaces. This is a special feature for
-use in the automatic test scripts; it ensures that the same output is generated
-for different internal link sizes.
+output a representation of the compiled code after compilation. Normally this
+information contains length and offset values; however, if <b>/Z</b> is also
+present, this data is replaced by spaces. This is a special feature for use in
+the automatic test scripts; it ensures that the same output is generated for
+different internal link sizes.
</P>
<P>
The <b>/D</b> modifier is a PCRE debugging feature, and is equivalent to
@@ -325,29 +380,29 @@ The <b>/D</b> modifier is a PCRE debugging feature, and is equivalent to
</P>
<P>
The <b>/F</b> modifier causes <b>pcretest</b> to flip the byte order of the
-fields in the compiled pattern that contain 2-byte and 4-byte numbers. This
-facility is for testing the feature in PCRE that allows it to execute patterns
-that were compiled on a host with a different endianness. This feature is not
-available when the POSIX interface to PCRE is being used, that is, when the
-<b>/P</b> pattern modifier is specified. See also the section about saving and
-reloading compiled patterns below.
+2-byte and 4-byte fields in the compiled pattern. This facility is for testing
+the feature in PCRE that allows it to execute patterns that were compiled on a
+host with a different endianness. This feature is not available when the POSIX
+interface to PCRE is being used, that is, when the <b>/P</b> pattern modifier is
+specified. See also the section about saving and reloading compiled patterns
+below.
</P>
<P>
The <b>/I</b> modifier requests that <b>pcretest</b> output information about the
compiled pattern (whether it is anchored, has a fixed first character, and
-so on). It does this by calling <b>pcre_fullinfo()</b> after compiling a
+so on). It does this by calling <b>pcre[16]_fullinfo()</b> after compiling a
pattern. If the pattern is studied, the results of that are also output.
</P>
<P>
The <b>/K</b> modifier requests <b>pcretest</b> to show names from backtracking
-control verbs that are returned from calls to <b>pcre_exec()</b>. It causes
-<b>pcretest</b> to create a <b>pcre_extra</b> block if one has not already been
-created by a call to <b>pcre_study()</b>, and to set the PCRE_EXTRA_MARK flag
-and the <b>mark</b> field within it, every time that <b>pcre_exec()</b> is
-called. If the variable that the <b>mark</b> field points to is non-NULL for a
-match, non-match, or partial match, <b>pcretest</b> prints the string to which
-it points. For a match, this is shown on a line by itself, tagged with "MK:".
-For a non-match it is added to the message.
+control verbs that are returned from calls to <b>pcre[16]_exec()</b>. It causes
+<b>pcretest</b> to create a <b>pcre[16]_extra</b> block if one has not already
+been created by a call to <b>pcre[16]_study()</b>, and to set the
+PCRE_EXTRA_MARK flag and the <b>mark</b> field within it, every time that
+<b>pcre[16]_exec()</b> is called. If the variable that the <b>mark</b> field
+points to is non-NULL for a match, non-match, or partial match, <b>pcretest</b>
+prints the string to which it points. For a match, this is shown on a line by
+itself, tagged with "MK:". For a non-match it is added to the message.
</P>
<P>
The <b>/L</b> modifier must be followed directly by the name of a locale, for
@@ -356,21 +411,21 @@ example,
/pattern/Lfr_FR
</pre>
For this reason, it must be the last modifier. The given locale is set,
-<b>pcre_maketables()</b> is called to build a set of character tables for the
-locale, and this is then passed to <b>pcre_compile()</b> when compiling the
-regular expression. Without an <b>/L</b> (or <b>/T</b>) modifier, NULL is passed
-as the tables pointer; that is, <b>/L</b> applies only to the expression on
-which it appears.
+<b>pcre[16]_maketables()</b> is called to build a set of character tables for
+the locale, and this is then passed to <b>pcre[16]_compile()</b> when compiling
+the regular expression. Without an <b>/L</b> (or <b>/T</b>) modifier, NULL is
+passed as the tables pointer; that is, <b>/L</b> applies only to the expression
+on which it appears.
</P>
<P>
-The <b>/M</b> modifier causes the size of memory block used to hold the compiled
-pattern to be output. This does not include the size of the <b>pcre</b> block;
-it is just the actual compiled data. If the pattern is successfully studied
-with the PCRE_STUDY_JIT_COMPILE option, the size of the JIT compiled code is
-also output.
+The <b>/M</b> modifier causes the size in bytes of the memory block used to hold
+the compiled pattern to be output. This does not include the size of the
+<b>pcre[16]</b> block; it is just the actual compiled data. If the pattern is
+successfully studied with the PCRE_STUDY_JIT_COMPILE option, the size of the
+JIT compiled code is also output.
</P>
<P>
-If the <b>/S</b> modifier appears once, it causes <b>pcre_study()</b> to be
+If the <b>/S</b> modifier appears once, it causes <b>pcre[16]_study()</b> to be
called after the expression has been compiled, and the results used when the
expression is matched. If <b>/S</b> appears twice, it suppresses studying, even
if it was requested externally by the <b>-s</b> command line option. This makes
@@ -380,21 +435,21 @@ files in a few cases where the output is different when the pattern is studied.
</P>
<P>
If the <b>/S</b> modifier is immediately followed by a + character, the call to
-<b>pcre_study()</b> is made with the PCRE_STUDY_JIT_COMPILE option, requesting
-just-in-time optimization support if it is available. Note that there is also a
-<b>/+</b> modifier; it must not be given immediately after <b>/S</b> because this
-will be misinterpreted. If JIT studying is successful, it will automatically be
-used when <b>pcre_exec()</b> is run, except when incompatible run-time options
-are specified. These include the partial matching options; a complete list is
-given in the
+<b>pcre[16]_study()</b> is made with the PCRE_STUDY_JIT_COMPILE option,
+requesting just-in-time optimization support if it is available. Note that
+there is also a <b>/+</b> modifier; it must not be given immediately after
+<b>/S</b> because this will be misinterpreted. If JIT studying is successful, it
+will automatically be used when <b>pcre[16]_exec()</b> is run, except when
+incompatible run-time options are specified. These include the partial matching
+options; a complete list is given in the
<a href="pcrejit.html"><b>pcrejit</b></a>
documentation. See also the <b>\J</b> escape sequence below for a way of
setting the size of the JIT stack.
</P>
<P>
The <b>/T</b> modifier must be followed by a single digit. It causes a specific
-set of built-in character tables to be passed to <b>pcre_compile()</b>. It is
-used in the standard PCRE tests to check behaviour with different character
+set of built-in character tables to be passed to <b>pcre[16]_compile()</b>. It
+is used in the standard PCRE tests to check behaviour with different character
tables. The digit specifies the tables as follows:
<pre>
0 the default ASCII tables, as distributed in
@@ -409,8 +464,9 @@ Using the POSIX wrapper API
</b><br>
<P>
The <b>/P</b> modifier causes <b>pcretest</b> to call PCRE via the POSIX wrapper
-API rather than its native API. When <b>/P</b> is set, the following modifiers
-set options for the <b>regcomp()</b> function:
+API rather than its native API. This supports only the 8-bit library. When
+<b>/P</b> is set, the following modifiers set options for the <b>regcomp()</b>
+function:
<pre>
/i REG_ICASE
/m REG_NEWLINE
@@ -423,9 +479,9 @@ set options for the <b>regcomp()</b> function:
The <b>/+</b> modifier works as described above. All other modifiers are
ignored.
</P>
-<br><a name="SEC5" href="#TOC1">DATA LINES</a><br>
+<br><a name="SEC6" href="#TOC1">DATA LINES</a><br>
<P>
-Before each data line is passed to <b>pcre_exec()</b>, leading and trailing
+Before each data line is passed to <b>pcre[16]_exec()</b>, leading and trailing
white space is removed, and it is then scanned for \ escapes. Some of these
are pretty esoteric features, intended for checking out some of the more
complicated features of PCRE. If you are just testing "ordinary" regular
@@ -441,53 +497,62 @@ recognized:
\r carriage return (\x0d)
\t tab (\x09)
\v vertical tab (\x0b)
- \nnn octal character (up to 3 octal digits)
- always a byte unless &#62; 255 in UTF-8 mode
+ \nnn octal character (up to 3 octal digits); always
+ a byte unless &#62; 255 in UTF-8 or 16-bit mode
\xhh hexadecimal byte (up to 2 hex digits)
- \x{hh...} hexadecimal character, any number of digits in UTF-8 mode
- \A pass the PCRE_ANCHORED option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
- \B pass the PCRE_NOTBOL option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
- \Cdd call pcre_copy_substring() for substring dd after a successful match (number less than 32)
- \Cname call pcre_copy_named_substring() for substring "name" after a successful match (name termin-
+ \x{hh...} hexadecimal character (any number of hex digits)
+ \A pass the PCRE_ANCHORED option to <b>pcre[16]_exec()</b> or <b>pcre[16]_dfa_exec()</b>
+ \B pass the PCRE_NOTBOL option to <b>pcre[16]_exec()</b> or <b>pcre[16]_dfa_exec()</b>
+ \Cdd call pcre[16]_copy_substring() for substring dd after a successful match (number less than 32)
+ \Cname call pcre[16]_copy_named_substring() for substring "name" after a successful match (name termin-
ated by next non alphanumeric character)
\C+ show the current captured substrings at callout time
\C- do not supply a callout function
\C!n return 1 instead of 0 when callout number n is reached
\C!n!m return 1 instead of 0 when callout number n is reached for the nth time
\C*n pass the number n (may be negative) as callout data; this is used as the callout return value
- \D use the <b>pcre_dfa_exec()</b> match function
- \F only shortest match for <b>pcre_dfa_exec()</b>
- \Gdd call pcre_get_substring() for substring dd after a successful match (number less than 32)
- \Gname call pcre_get_named_substring() for substring "name" after a successful match (name termin-
+ \D use the <b>pcre[16]_dfa_exec()</b> match function
+ \F only shortest match for <b>pcre[16]_dfa_exec()</b>
+ \Gdd call pcre[16]_get_substring() for substring dd after a successful match (number less than 32)
+ \Gname call pcre[16]_get_named_substring() for substring "name" after a successful match (name termin-
ated by next non-alphanumeric character)
\Jdd set up a JIT stack of dd kilobytes maximum (any number of digits)
- \L call pcre_get_substringlist() after a successful match
+ \L call pcre[16]_get_substringlist() after a successful match
\M discover the minimum MATCH_LIMIT and MATCH_LIMIT_RECURSION settings
- \N pass the PCRE_NOTEMPTY option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>; if used twice, pass the
+ \N pass the PCRE_NOTEMPTY option to <b>pcre[16]_exec()</b> or <b>pcre[16]_dfa_exec()</b>; if used twice, pass the
PCRE_NOTEMPTY_ATSTART option
- \Odd set the size of the output vector passed to <b>pcre_exec()</b> to dd (any number of digits)
- \P pass the PCRE_PARTIAL_SOFT option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>; if used twice, pass the
+ \Odd set the size of the output vector passed to <b>pcre[16]_exec()</b> to dd (any number of digits)
+ \P pass the PCRE_PARTIAL_SOFT option to <b>pcre[16]_exec()</b> or <b>pcre[16]_dfa_exec()</b>; if used twice, pass the
PCRE_PARTIAL_HARD option
\Qdd set the PCRE_MATCH_LIMIT_RECURSION limit to dd (any number of digits)
- \R pass the PCRE_DFA_RESTART option to <b>pcre_dfa_exec()</b>
+ \R pass the PCRE_DFA_RESTART option to <b>pcre[16]_dfa_exec()</b>
\S output details of memory get/free calls during matching
- \Y pass the PCRE_NO_START_OPTIMIZE option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
- \Z pass the PCRE_NOTEOL option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
- \? pass the PCRE_NO_UTF8_CHECK option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
+ \Y pass the PCRE_NO_START_OPTIMIZE option to <b>pcre[16]_exec()</b> or <b>pcre[16]_dfa_exec()</b>
+ \Z pass the PCRE_NOTEOL option to <b>pcre[16]_exec()</b> or <b>pcre[16]_dfa_exec()</b>
+ \? pass the PCRE_NO_UTF[8|16]_CHECK option to <b>pcre[16]_exec()</b> or <b>pcre[16]_dfa_exec()</b>
\&#62;dd start the match at offset dd (optional "-"; then any number of digits); this sets the <i>startoffset</i>
- argument for <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
- \&#60;cr&#62; pass the PCRE_NEWLINE_CR option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
- \&#60;lf&#62; pass the PCRE_NEWLINE_LF option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
- \&#60;crlf&#62; pass the PCRE_NEWLINE_CRLF option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
- \&#60;anycrlf&#62; pass the PCRE_NEWLINE_ANYCRLF option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
- \&#60;any&#62; pass the PCRE_NEWLINE_ANY option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
+ argument for <b>pcre[16]_exec()</b> or <b>pcre[16]_dfa_exec()</b>
+ \&#60;cr&#62; pass the PCRE_NEWLINE_CR option to <b>pcre[16]_exec()</b> or <b>pcre[16]_dfa_exec()</b>
+ \&#60;lf&#62; pass the PCRE_NEWLINE_LF option to <b>pcre[16]_exec()</b> or <b>pcre[16]_dfa_exec()</b>
+ \&#60;crlf&#62; pass the PCRE_NEWLINE_CRLF option to <b>pcre[16]_exec()</b> or <b>pcre[16]_dfa_exec()</b>
+ \&#60;anycrlf&#62; pass the PCRE_NEWLINE_ANYCRLF option to <b>pcre[16]_exec()</b> or <b>pcre[16]_dfa_exec()</b>
+ \&#60;any&#62; pass the PCRE_NEWLINE_ANY option to <b>pcre[16]_exec()</b> or <b>pcre[16]_dfa_exec()</b>
</pre>
-Note that \xhh always specifies one byte, even in UTF-8 mode; this makes it
-possible to construct invalid UTF-8 sequences for testing purposes. On the
-other hand, \x{hh} is interpreted as a UTF-8 character in UTF-8 mode,
-generating more than one byte if the value is greater than 127. When not in
-UTF-8 mode, it generates one byte for values less than 256, and causes an error
-for greater values.
+The use of \x{hh...} is not dependent on the use of the <b>/8</b> modifier on
+the pattern. It is recognized always. There may be any number of hexadecimal
+digits inside the braces; invalid values provoke error messages.
+</P>
+<P>
+Note that \xhh specifies one byte in UTF-8 mode; this makes it possible to
+construct invalid UTF-8 sequences for testing purposes. On the other hand,
+\x{hh} is interpreted as a UTF-8 character in UTF-8 mode, generating more than
+one byte if the value is greater than 127. When testing the 8-bit library not
+in UTF-8 mode, \x{hh} generates one byte for values less than 256, and causes
+an error for greater values.
+</P>
+<P>
+In UTF-16 mode, all 4-digit \x{hhhh} values are accepted. This makes it
+possible to construct invalid UTF-16 sequences for testing purposes.
</P>
<P>
The escapes that specify line ending sequences are literal strings, exactly as
@@ -506,13 +571,13 @@ is not being used. Providing a stack that is larger than the default 32K is
necessary only for very complicated patterns.
</P>
<P>
-If \M is present, <b>pcretest</b> calls <b>pcre_exec()</b> several times, with
-different values in the <i>match_limit</i> and <i>match_limit_recursion</i>
-fields of the <b>pcre_extra</b> data structure, until it finds the minimum
-numbers for each parameter that allow <b>pcre_exec()</b> to complete without
+If \M is present, <b>pcretest</b> calls <b>pcre[16]_exec()</b> several times,
+with different values in the <i>match_limit</i> and <i>match_limit_recursion</i>
+fields of the <b>pcre[16]_extra</b> data structure, until it finds the minimum
+numbers for each parameter that allow <b>pcre[16]_exec()</b> to complete without
error. Because this is testing a specific feature of the normal interpretive
-<b>pcre_exec()</b> execution, the use of any JIT optimization that might have
-been set up by the <b>/S+</b> qualifier of <b>-s+</b> option is disabled.
+<b>pcre[16]_exec()</b> execution, the use of any JIT optimization that might
+have been set up by the <b>/S+</b> qualifier of <b>-s+</b> option is disabled.
</P>
<P>
The <i>match_limit</i> number is a measure of the amount of backtracking
@@ -526,7 +591,7 @@ needed to complete the match attempt.
<P>
When \O is used, the value specified may be higher or lower than the size set
by the <b>-O</b> command line option (or defaulted to 45); \O applies only to
-the call of <b>pcre_exec()</b> for the line in which it appears.
+the call of <b>pcre[16]_exec()</b> for the line in which it appears.
</P>
<P>
If the <b>/P</b> modifier was present on the pattern, causing the POSIX wrapper
@@ -534,20 +599,11 @@ API to be used, the only option-setting sequences that have any effect are \B,
\N, and \Z, causing REG_NOTBOL, REG_NOTEMPTY, and REG_NOTEOL, respectively,
to be passed to <b>regexec()</b>.
</P>
-<P>
-The use of \x{hh...} to represent UTF-8 characters is not dependent on the use
-of the <b>/8</b> modifier on the pattern. It is recognized always. There may be
-any number of hexadecimal digits inside the braces. The result is from one to
-six bytes, encoded according to the original UTF-8 rules of RFC 2279. This
-allows for values in the range 0 to 0x7FFFFFFF. Note that not all of those are
-valid Unicode code points, or indeed valid UTF-8 characters according to the
-later rules in RFC 3629.
-</P>
-<br><a name="SEC6" href="#TOC1">THE ALTERNATIVE MATCHING FUNCTION</a><br>
+<br><a name="SEC7" href="#TOC1">THE ALTERNATIVE MATCHING FUNCTION</a><br>
<P>
By default, <b>pcretest</b> uses the standard PCRE matching function,
-<b>pcre_exec()</b> to match each data line. From release 6.0, PCRE supports an
-alternative matching function, <b>pcre_dfa_test()</b>, which operates in a
+<b>pcre[16]_exec()</b> to match each data line. PCRE also supports an
+alternative matching function, <b>pcre[16]_dfa_test()</b>, which operates in a
different way, and has some restrictions. The differences between the two
functions are described in the
<a href="pcrematching.html"><b>pcrematching</b></a>
@@ -555,30 +611,29 @@ documentation.
</P>
<P>
If a data line contains the \D escape sequence, or if the command line
-contains the <b>-dfa</b> option, the alternative matching function is called.
+contains the <b>-dfa</b> option, the alternative matching function is used.
This function finds all possible matches at a given point. If, however, the \F
escape sequence is present in the data line, it stops after the first match is
found. This is always the shortest possible match.
</P>
-<br><a name="SEC7" href="#TOC1">DEFAULT OUTPUT FROM PCRETEST</a><br>
+<br><a name="SEC8" href="#TOC1">DEFAULT OUTPUT FROM PCRETEST</a><br>
<P>
This section describes the output when the normal matching function,
-<b>pcre_exec()</b>, is being used.
+<b>pcre[16]_exec()</b>, is being used.
</P>
<P>
When a match succeeds, <b>pcretest</b> outputs the list of captured substrings
-that <b>pcre_exec()</b> returns, starting with number 0 for the string that
+that <b>pcre[16]_exec()</b> returns, starting with number 0 for the string that
matched the whole pattern. Otherwise, it outputs "No match" when the return is
PCRE_ERROR_NOMATCH, and "Partial match:" followed by the partially matching
-substring when <b>pcre_exec()</b> returns PCRE_ERROR_PARTIAL. (Note that this is
-the entire substring that was inspected during the partial match; it may
-include characters before the actual match start if a lookbehind assertion,
+substring when <b>pcre[16]_exec()</b> returns PCRE_ERROR_PARTIAL. (Note that
+this is the entire substring that was inspected during the partial match; it
+may include characters before the actual match start if a lookbehind assertion,
\K, \b, or \B was involved.) For any other return, <b>pcretest</b> outputs
the PCRE negative error number and a short descriptive phrase. If the error is
-a failed UTF-8 string check, the byte offset of the start of the failing
-character and the reason code are also output, provided that the size of the
-output vector is at least two. Here is an example of an interactive
-<b>pcretest</b> run.
+a failed UTF string check, the offset of the start of the failing character and
+the reason code are also output, provided that the size of the output vector is
+at least two. Here is an example of an interactive <b>pcretest</b> run.
<pre>
$ pcretest
PCRE version 8.13 2011-04-30
@@ -591,7 +646,7 @@ output vector is at least two. Here is an example of an interactive
No match
</pre>
Unset capturing substrings that are not followed by one that is set are not
-returned by <b>pcre_exec()</b>, and are not shown by <b>pcretest</b>. In the
+returned by <b>pcre[16]_exec()</b>, and are not shown by <b>pcretest</b>. In the
following example, there are two capturing substrings, but when the first data
line is matched, the second, unset substring is not shown. An "internal" unset
substring is shown as "&#60;unset&#62;", as for the second data line.
@@ -605,11 +660,12 @@ substring is shown as "&#60;unset&#62;", as for the second data line.
1: &#60;unset&#62;
2: b
</pre>
-If the strings contain any non-printing characters, they are output as \0x
-escapes, or as \x{...} escapes if the <b>/8</b> modifier was present on the
-pattern. See below for the definition of non-printing characters. If the
-pattern has the <b>/+</b> modifier, the output for substring 0 is followed by
-the the rest of the subject string, identified by "0+" like this:
+If the strings contain any non-printing characters, they are output as \xhh
+escapes if the value is less than 256 and UTF mode is not set. Otherwise they
+are output as \x{hh...} escapes. See below for the definition of non-printing
+characters. If the pattern has the <b>/+</b> modifier, the output for substring
+0 is followed by the the rest of the subject string, identified by "0+" like
+this:
<pre>
re&#62; /cat/+
data&#62; cataract
@@ -651,9 +707,9 @@ prompt is used for continuations), data lines may not. However newlines can be
included in data by means of the \n escape (or \r, \r\n, etc., depending on
the newline sequence setting).
</P>
-<br><a name="SEC8" href="#TOC1">OUTPUT FROM THE ALTERNATIVE MATCHING FUNCTION</a><br>
+<br><a name="SEC9" href="#TOC1">OUTPUT FROM THE ALTERNATIVE MATCHING FUNCTION</a><br>
<P>
-When the alternative matching function, <b>pcre_dfa_exec()</b>, is used (by
+When the alternative matching function, <b>pcre[16]_dfa_exec()</b>, is used (by
means of the \D escape sequence or the <b>-dfa</b> command line option), the
output consists of a list of all the matches that start at the first point in
the subject where there is at least one match. For example:
@@ -687,7 +743,7 @@ at the end of the longest match. For example:
Since the matching function does not support substring capture, the escape
sequences that are concerned with captured substrings are not relevant.
</P>
-<br><a name="SEC9" href="#TOC1">RESTARTING AFTER A PARTIAL MATCH</a><br>
+<br><a name="SEC10" href="#TOC1">RESTARTING AFTER A PARTIAL MATCH</a><br>
<P>
When the alternative matching function has given the PCRE_ERROR_PARTIAL return,
indicating that the subject partially matched the pattern, you can restart the
@@ -704,21 +760,21 @@ For further information about partial matching, see the
<a href="pcrepartial.html"><b>pcrepartial</b></a>
documentation.
</P>
-<br><a name="SEC10" href="#TOC1">CALLOUTS</a><br>
+<br><a name="SEC11" href="#TOC1">CALLOUTS</a><br>
<P>
If the pattern contains any callout requests, <b>pcretest</b>'s callout function
is called during matching. This works with both matching functions. By default,
the called function displays the callout number, the start and current
positions in the text at the callout time, and the next pattern item to be
-tested. For example, the output
+tested. For example:
<pre>
---&#62;pqrabcdef
0 ^ ^ \d
</pre>
-indicates that callout number 0 occurred for a match attempt starting at the
-fourth character of the subject string, when the pointer was at the seventh
-character of the data, and when the next pattern item was \d. Just one
-circumflex is output if the start and current positions are the same.
+This output indicates that callout number 0 occurred for a match attempt
+starting at the fourth character of the subject string, when the pointer was at
+the seventh character of the data, and when the next pattern item was \d. Just
+one circumflex is output if the start and current positions are the same.
</P>
<P>
Callouts numbered 255 are assumed to be automatic callouts, inserted as a
@@ -765,7 +821,7 @@ the
<a href="pcrecallout.html"><b>pcrecallout</b></a>
documentation.
</P>
-<br><a name="SEC11" href="#TOC1">NON-PRINTING CHARACTERS</a><br>
+<br><a name="SEC12" href="#TOC1">NON-PRINTING CHARACTERS</a><br>
<P>
When <b>pcretest</b> is outputting text in the compiled version of a pattern,
bytes other than 32-126 are always treated as non-printing characters are are
@@ -777,7 +833,7 @@ string, it behaves in the same way, unless a different locale has been set for
the pattern (using the <b>/L</b> modifier). In this case, the <b>isprint()</b>
function to distinguish printing and non-printing characters.
</P>
-<br><a name="SEC12" href="#TOC1">SAVING AND RELOADING COMPILED PATTERNS</a><br>
+<br><a name="SEC13" href="#TOC1">SAVING AND RELOADING COMPILED PATTERNS</a><br>
<P>
The facilities described in this section are not available when the POSIX
interface to PCRE is being used, that is, when the <b>/P</b> pattern modifier is
@@ -825,7 +881,15 @@ been loaded, <b>pcretest</b> proceeds to read data lines in the usual way.
You can copy a file written by <b>pcretest</b> to a different host and reload it
there, even if the new host has opposite endianness to the one on which the
pattern was compiled. For example, you can compile on an i86 machine and run on
-a SPARC machine.
+a SPARC machine. When a pattern is reloaded on a host with different
+endianness, the confirmation message is changed to:
+<pre>
+ Compiled pattern (byte-inverted) loaded from /some/file
+</pre>
+The test suite contains some saved pre-compiled patterns with different
+endianness. These are reloaded using "&#60;!" instead of just "&#60;". This suppresses
+the "(byte-inverted)" text so that the output is the same on all hosts. It also
+forces debugging output once the pattern has been reloaded.
</P>
<P>
File names for saving and reloading can be absolute or relative, but note that
@@ -842,13 +906,13 @@ string using a reloaded pattern is likely to cause <b>pcretest</b> to crash.
Finally, if you attempt to load a file that is not in the correct format, the
result is undefined.
</P>
-<br><a name="SEC13" href="#TOC1">SEE ALSO</a><br>
+<br><a name="SEC14" href="#TOC1">SEE ALSO</a><br>
<P>
-<b>pcre</b>(3), <b>pcreapi</b>(3), <b>pcrecallout</b>(3), <b>pcrejit</b>,
-<b>pcrematching</b>(3), <b>pcrepartial</b>(d), <b>pcrepattern</b>(3),
-<b>pcreprecompile</b>(3).
+<b>pcre</b>(3), <b>pcre16</b>(3), <b>pcreapi</b>(3), <b>pcrecallout</b>(3),
+<b>pcrejit</b>, <b>pcrematching</b>(3), <b>pcrepartial</b>(d),
+<b>pcrepattern</b>(3), <b>pcreprecompile</b>(3).
</P>
-<br><a name="SEC14" href="#TOC1">AUTHOR</a><br>
+<br><a name="SEC15" href="#TOC1">AUTHOR</a><br>
<P>
Philip Hazel
<br>
@@ -857,11 +921,11 @@ University Computing Service
Cambridge CB2 3QH, England.
<br>
</P>
-<br><a name="SEC15" href="#TOC1">REVISION</a><br>
+<br><a name="SEC16" href="#TOC1">REVISION</a><br>
<P>
-Last updated: 02 December 2011
+Last updated: 13 January 2012
<br>
-Copyright &copy; 1997-2011 University of Cambridge.
+Copyright &copy; 1997-2012 University of Cambridge.
<br>
<p>
Return to the <a href="index.html">PCRE index page</a>.
diff --git a/doc/html/pcreunicode.html b/doc/html/pcreunicode.html
index 96fa62e..ef3efef 100644
--- a/doc/html/pcreunicode.html
+++ b/doc/html/pcreunicode.html
@@ -13,26 +13,51 @@ from the original man page. If there is any nonsense in it, please consult the
man page, in case the conversion went wrong.
<br>
<br><b>
-UTF-8 AND UNICODE PROPERTY SUPPORT
+UTF-8, UTF-16, AND UNICODE PROPERTY SUPPORT
</b><br>
<P>
-In order process UTF-8 strings, you must build PCRE to include UTF-8 support in
-the code, and, in addition, you must call
+From Release 8.30, in addition to its previous UTF-8 support, PCRE also
+supports UTF-16 by means of a separate 16-bit library. This can be built as
+well as, or instead of, the 8-bit library.
+</P>
+<br><b>
+UTF-8 SUPPORT
+</b><br>
+<P>
+In order process UTF-8 strings, you must build PCRE's 8-bit library with UTF
+support, and, in addition, you must call
<a href="pcre_compile.html"><b>pcre_compile()</b></a>
with the PCRE_UTF8 option flag, or the pattern must start with the sequence
(*UTF8). When either of these is the case, both the pattern and any subject
strings that are matched against it are treated as UTF-8 strings instead of
-strings of 1-byte characters. PCRE does not support any other formats (in
-particular, it does not support UTF-16).
+strings of 1-byte characters.
+</P>
+<br><b>
+UTF-16 SUPPORT
+</b><br>
+<P>
+In order process UTF-16 strings, you must build PCRE's 16-bit library with UTF
+support, and, in addition, you must call
+<a href="pcre16_compile.html"><b>pcre16_compile()</b></a>
+with the PCRE_UTF16 option flag, or the pattern must start with the sequence
+(*UTF16). When either of these is the case, both the pattern and any subject
+strings that are matched against it are treated as UTF-16 strings instead of
+strings of 16-bit characters.
</P>
+<br><b>
+UTF SUPPORT OVERHEAD
+</b><br>
<P>
-If you compile PCRE with UTF-8 support, but do not use it at run time, the
+If you compile PCRE with UTF support, but do not use it at run time, the
library will be a bit bigger, but the additional run time overhead is limited
-to testing the PCRE_UTF8 flag occasionally, so should not be very big.
+to testing the PCRE_UTF8/16 flag occasionally, so should not be very big.
</P>
+<br><b>
+UNICODE PROPERTY SUPPORT
+</b><br>
<P>
-If PCRE is built with Unicode character property support (which implies UTF-8
-support), the escape sequences \p{..}, \P{..}, and \X are supported.
+If PCRE is built with Unicode character property support (which implies UTF
+support), the escape sequences \p{..}, \P{..}, and \X can be used.
The available properties that can be tested are limited to the general
category properties such as Lu for an upper case letter or Nd for a decimal
number, the Unicode script names such as Arabic or Han, and the derived
@@ -47,23 +72,20 @@ compatibility with Perl 5.6. PCRE does not support this.
Validity of UTF-8 strings
</b><br>
<P>
-When you set the PCRE_UTF8 flag, the strings passed as patterns and subjects
-are (by default) checked for validity on entry to the relevant functions. From
-release 7.3 of PCRE, the check is according the rules of RFC 3629, which are
-themselves derived from the Unicode specification. Earlier releases of PCRE
-followed the rules of RFC 2279, which allows the full range of 31-bit values (0
-to 0x7FFFFFFF). The current check allows only values in the range U+0 to
-U+10FFFF, excluding U+D800 to U+DFFF.
+When you set the PCRE_UTF8 flag, the byte strings passed as patterns and
+subjects are (by default) checked for validity on entry to the relevant
+functions. From release 7.3 of PCRE, the check is according the rules of RFC
+3629, which are themselves derived from the Unicode specification. Earlier
+releases of PCRE followed the rules of RFC 2279, which allows the full range of
+31-bit values (0 to 0x7FFFFFFF). The current check allows only values in the
+range U+0 to U+10FFFF, excluding U+D800 to U+DFFF.
</P>
<P>
-The excluded code points are the "Low Surrogate Area" of Unicode, of which the
-Unicode Standard says this: "The Low Surrogate Area does not contain any
-character assignments, consequently no character code charts or namelists are
-provided for this area. Surrogates are reserved for use with UTF-16 and then
-must be used in pairs." The code points that are encoded by UTF-16 pairs are
-available as independent code points in the UTF-8 encoding. (In other words,
-the whole surrogate thing is a fudge for UTF-16 which unfortunately messes up
-UTF-8.)
+The excluded code points are the "Surrogate Area" of Unicode. They are reserved
+for use by UTF-16, where they are used in pairs to encode codepoints with
+values greater than 0xFFFF. The code points that are encoded by UTF-16 pairs
+are available independently in the UTF-8 encoding. (In other words, the whole
+surrogate thing is a fudge for UTF-16 which unfortunately messes up UTF-8.)
</P>
<P>
If an invalid UTF-8 string is passed to PCRE, an error return is given. At
@@ -97,48 +119,76 @@ encoded in a UTF-8-like manner as per the old RFC, you can set
PCRE_NO_UTF8_CHECK to bypass the more restrictive test. However, in this
situation, you will have to apply your own validity check, and avoid the use of
JIT optimization.
+<a name="utf16strings"></a></P>
+<br><b>
+Validity of UTF-16 strings
+</b><br>
+<P>
+When you set the PCRE_UTF16 flag, the strings of 16-bit data units that are
+passed as patterns and subjects are (by default) checked for validity on entry
+to the relevant functions. Values other than those in the surrogate range
+U+D800 to U+DFFF are independent code points. Values in the surrogate range
+must be used in pairs in the correct manner.
+</P>
+<P>
+If an invalid UTF-16 string is passed to PCRE, an error return is given. At
+compile time, the only additional information is the offset to the first data
+unit of the failing character. The runtime functions <b>pcre16_exec()</b> and
+<b>pcre16_dfa_exec()</b> also pass back this information, as well as a more
+detailed reason code if the caller has provided memory in which to do this.
+</P>
+<P>
+In some situations, you may already know that your strings are valid, and
+therefore want to skip these checks in order to improve performance. If you set
+the PCRE_NO_UTF16_CHECK flag at compile time or at run time, PCRE assumes that
+the pattern or subject it is given (respectively) contains only valid UTF-16
+sequences. In this case, it does not diagnose an invalid UTF-16 string.
</P>
<br><b>
-General comments about UTF-8 mode
+General comments about UTF modes
</b><br>
<P>
-1. An unbraced hexadecimal escape sequence (such as \xb3) matches a two-byte
-UTF-8 character if the value is greater than 127.
+1. Codepoints less than 256 can be specified by either braced or unbraced
+hexadecimal escape sequences (for example, \x{b3} or \xb3). Larger values
+have to use braced sequences.
</P>
<P>
-2. Octal numbers up to \777 are recognized, and match two-byte UTF-8
-characters for values greater than \177.
+2. Octal numbers up to \777 are recognized, and in UTF-8 mode, they match
+two-byte characters for values greater than \177.
</P>
<P>
-3. Repeat quantifiers apply to complete UTF-8 characters, not to individual
-bytes, for example: \x{100}{3}.
+3. Repeat quantifiers apply to complete UTF characters, not to individual
+data units, for example: \x{100}{3}.
</P>
<P>
-4. The dot metacharacter matches one UTF-8 character instead of a single byte.
+4. The dot metacharacter matches one UTF character instead of a single data
+unit.
</P>
<P>
-5. The escape sequence \C can be used to match a single byte in UTF-8 mode,
-but its use can lead to some strange effects because it breaks up multibyte
-characters (see the description of \C in the
+5. The escape sequence \C can be used to match a single byte in UTF-8 mode, or
+a single 16-bit data unit in UTF-16 mode, but its use can lead to some strange
+effects because it breaks up multi-unit characters (see the description of \C
+in the
<a href="pcrepattern.html"><b>pcrepattern</b></a>
documentation). The use of \C is not supported in the alternative matching
-function <b>pcre_dfa_exec()</b>, nor is it supported in UTF-8 mode by the JIT
-optimization of <b>pcre_exec()</b>. If JIT optimization is requested for a UTF-8
-pattern that contains \C, it will not succeed, and so the matching will be
-carried out by the normal interpretive function.
+function <b>pcre[16]_dfa_exec()</b>, nor is it supported in UTF mode by the JIT
+optimization of <b>pcre[16]_exec()</b>. If JIT optimization is requested for a
+UTF pattern that contains \C, it will not succeed, and so the matching will
+be carried out by the normal interpretive function.
</P>
<P>
6. The character escapes \b, \B, \d, \D, \s, \S, \w, and \W correctly
test characters of any code value, but, by default, the characters that PCRE
-recognizes as digits, spaces, or word characters remain the same set as before,
-all with values less than 256. This remains true even when PCRE is built to
-include Unicode property support, because to do otherwise would slow down PCRE
-in many common cases. Note in particular that this applies to \b and \B,
-because they are defined in terms of \w and \W. If you really want to test
-for a wider sense of, say, "digit", you can use explicit Unicode property tests
-such as \p{Nd}. Alternatively, if you set the PCRE_UCP option, the way that
-the character escapes work is changed so that Unicode properties are used to
-determine which characters match. There are more details in the section on
+recognizes as digits, spaces, or word characters remain the same set as in
+non-UTF mode, all with values less than 256. This remains true even when PCRE
+is built to include Unicode property support, because to do otherwise would
+slow down PCRE in many common cases. Note in particular that this applies to
+\b and \B, because they are defined in terms of \w and \W. If you really
+want to test for a wider sense of, say, "digit", you can use explicit Unicode
+property tests such as \p{Nd}. Alternatively, if you set the PCRE_UCP option,
+the way that the character escapes work is changed so that Unicode properties
+are used to determine which characters match. There are more details in the
+section on
<a href="pcrepattern.html#genericchartypes">generic character types</a>
in the
<a href="pcrepattern.html"><b>pcrepattern</b></a>
@@ -178,9 +228,9 @@ Cambridge CB2 3QH, England.
REVISION
</b><br>
<P>
-Last updated: 19 October 2011
+Last updated: 13 January 2012
<br>
-Copyright &copy; 1997-2011 University of Cambridge.
+Copyright &copy; 1997-2012 University of Cambridge.
<br>
<p>
Return to the <a href="index.html">PCRE index page</a>.
diff --git a/doc/pcre-config.txt b/doc/pcre-config.txt
index c979d45..ec89b32 100644
--- a/doc/pcre-config.txt
+++ b/doc/pcre-config.txt
@@ -8,35 +8,49 @@ NAME
SYNOPSIS
pcre-config [--prefix] [--exec-prefix] [--version] [--libs]
- [--libs-posix] [--cflags] [--cflags-posix]
+ [--libs16] [--libs-cpp] [--libs-posix] [--cflags]
+ [--cflags-posix]
DESCRIPTION
pcre-config returns the configuration of the installed PCRE libraries
- and the options required to compile a program to use them.
+ and the options required to compile a program to use them. Some of the
+ options apply only to the 8-bit or 16-bit libraries, respectively, and
+ are not available if only one of those libraries has been built. If an
+ unavailable option is encountered, the "usage" information is output.
OPTIONS
--prefix Writes the directory prefix used in the PCRE installation for
- architecture independent files (/usr on many systems,
+ architecture independent files (/usr on many systems,
/usr/local on some systems) to the standard output.
--exec-prefix
Writes the directory prefix used in the PCRE installation for
- architecture dependent files (normally the same as --prefix)
+ architecture dependent files (normally the same as --prefix)
to the standard output.
- --version Writes the version number of the installed PCRE libraries to
+ --version Writes the version number of the installed PCRE libraries to
the standard output.
- --libs Writes to the standard output the command line options
- required to link with PCRE (-lpcre on many systems).
+ --libs Writes to the standard output the command line options
+ required to link with the 8-bit PCRE library (-lpcre on many
+ systems).
+
+ --libs16 Writes to the standard output the command line options
+ required to link with the 16-bit PCRE library (-lpcre16 on
+ many systems).
+
+ --libs-cpp
+ Writes to the standard output the command line options
+ required to link with PCRE's C++ wrapper library (-lpcrecpp
+ -lpcre on many systems).
--libs-posix
Writes to the standard output the command line options
- required to link with the PCRE posix emulation library
+ required to link with PCRE's POSIX API wrapper library
(-lpcreposix -lpcre on many systems).
--cflags Writes to the standard output the command line options
@@ -45,7 +59,7 @@ OPTIONS
--cflags-posix
Writes to the standard output the command line options
- required to compile files that use the PCRE posix emulation
+ required to compile files that use PCRE's POSIX API wrapper
library (this may include some -I options, but is blank on
many systems).
@@ -58,10 +72,10 @@ SEE ALSO
AUTHOR
This manual page was originally written by Mark Baker for the Debian
- GNU/Linux system. It has been slightly revised as a generic PCRE man
- page.
+ GNU/Linux system. It has been subsequently revised as a generic PCRE
+ man page.
REVISION
- Last updated: 18 April 2007
+ Last updated: 01 January 2012
diff --git a/doc/pcre.txt b/doc/pcre.txt
index 4750c59..68e0142 100644
--- a/doc/pcre.txt
+++ b/doc/pcre.txt
@@ -25,10 +25,26 @@ INTRODUCTION
items, and there is an option for requesting some minor changes that
give better JavaScript compatibility.
+ Starting with release 8.30, it is possible to compile two separate PCRE
+ libraries: the original, which supports 8-bit character strings
+ (including UTF-8 strings), and a second library that supports 16-bit
+ character strings (including UTF-16 strings). The build process allows
+ either one or both to be built. The majority of the work to make this
+ possible was done by Zoltan Herczeg.
+
+ The two libraries contain identical sets of functions, except that the
+ names in the 16-bit library start with pcre16_ instead of pcre_. To
+ avoid over-complication and reduce the documentation maintenance load,
+ most of the documentation describes the 8-bit library, with the differ-
+ ences for the 16-bit library described separately in the pcre16 page.
+ References to functions or structures of the form pcre[16]_xxx should
+ be read as meaning "pcre_xxx when using the 8-bit library and
+ pcre16_xxx when using the 16-bit library".
+
The current implementation of PCRE corresponds approximately with Perl
- 5.12, including support for UTF-8 encoded strings and Unicode general
- category properties. However, UTF-8 and Unicode support has to be
- explicitly enabled; it is not the default. The Unicode tables corre-
+ 5.12, including support for UTF-8/16 encoded strings and Unicode gen-
+ eral category properties. However, UTF-8/16 and Unicode support has to
+ be explicitly enabled; it is not the default. The Unicode tables corre-
spond to Unicode release 6.0.0.
In addition to the Perl-compatible matching function, PCRE contains an
@@ -39,52 +55,54 @@ INTRODUCTION
PCRE is written in C and released as a C library. A number of people
have written wrappers and interfaces of various kinds. In particular,
- Google Inc. have provided a comprehensive C++ wrapper. This is now
- included as part of the PCRE distribution. The pcrecpp page has details
- of this interface. Other people's contributions can be found in the
- Contrib directory at the primary FTP site, which is:
+ Google Inc. have provided a comprehensive C++ wrapper for the 8-bit
+ library. This is now included as part of the PCRE distribution. The
+ pcrecpp page has details of this interface. Other people's contribu-
+ tions can be found in the Contrib directory at the primary FTP site,
+ which is:
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre
- Details of exactly which Perl regular expression features are and are
+ Details of exactly which Perl regular expression features are and are
not supported by PCRE are given in separate documents. See the pcrepat-
- tern and pcrecompat pages. There is a syntax summary in the pcresyntax
+ tern and pcrecompat pages. There is a syntax summary in the pcresyntax
page.
- Some features of PCRE can be included, excluded, or changed when the
- library is built. The pcre_config() function makes it possible for a
- client to discover which features are available. The features them-
- selves are described in the pcrebuild page. Documentation about build-
- ing PCRE for various operating systems can be found in the README and
+ Some features of PCRE can be included, excluded, or changed when the
+ library is built. The pcre_config() function makes it possible for a
+ client to discover which features are available. The features them-
+ selves are described in the pcrebuild page. Documentation about build-
+ ing PCRE for various operating systems can be found in the README and
NON-UNIX-USE files in the source distribution.
- The library contains a number of undocumented internal functions and
- data tables that are used by more than one of the exported external
- functions, but which are not intended for use by external callers.
- Their names all begin with "_pcre_", which hopefully will not provoke
- any name clashes. In some environments, it is possible to control which
- external symbols are exported when a shared library is built, and in
- these cases the undocumented symbols are not exported.
+ The libraries contains a number of undocumented internal functions and
+ data tables that are used by more than one of the exported external
+ functions, but which are not intended for use by external callers.
+ Their names all begin with "_pcre_" or "_pcre16_", which hopefully will
+ not provoke any name clashes. In some environments, it is possible to
+ control which external symbols are exported when a shared library is
+ built, and in these cases the undocumented symbols are not exported.
USER DOCUMENTATION
- The user documentation for PCRE comprises a number of different sec-
- tions. In the "man" format, each of these is a separate "man page". In
- the HTML format, each is a separate page, linked from the index page.
- In the plain text format, all the sections, except the pcredemo sec-
+ The user documentation for PCRE comprises a number of different sec-
+ tions. In the "man" format, each of these is a separate "man page". In
+ the HTML format, each is a separate page, linked from the index page.
+ In the plain text format, all the sections, except the pcredemo sec-
tion, are concatenated, for ease of searching. The sections are as fol-
lows:
pcre this document
+ pcre16 details of the 16-bit library
pcre-config show PCRE installation configuration information
pcreapi details of PCRE's native C API
pcrebuild options for building PCRE
pcrecallout details of the callout feature
pcrecompat discussion of Perl compatibility
- pcrecpp details of the C++ wrapper
+ pcrecpp details of the C++ wrapper for the 8-bit library
pcredemo a demonstration C program that uses PCRE
- pcregrep description of the pcregrep command
+ pcregrep description of the pcregrep command (8-bit only)
pcrejit discussion of the just-in-time optimization support
pcrelimits details of size and other limits
pcrematching discussion of the two matching algorithms
@@ -92,16 +110,16 @@ USER DOCUMENTATION
pcrepattern syntax and semantics of supported
regular expressions
pcreperform discussion of performance issues
- pcreposix the POSIX-compatible C API
+ pcreposix the POSIX-compatible C API for the 8-bit library
pcreprecompile details of saving and re-using precompiled patterns
pcresample discussion of the pcredemo program
pcrestack discussion of stack usage
pcresyntax quick syntax reference
pcretest description of the pcretest testing command
- pcreunicode discussion of Unicode and UTF-8 support
+ pcreunicode discussion of Unicode and UTF-8/16 support
- In addition, in the "man" and HTML formats, there is a short page for
- each C library function, listing its arguments and results.
+ In addition, in the "man" and HTML formats, there is a short page for
+ each 8-bit C library function, listing its arguments and results.
AUTHOR
@@ -110,18 +128,343 @@ AUTHOR
University Computing Service
Cambridge CB2 3QH, England.
- Putting an actual email address here seems to have been a spam magnet,
- so I've taken it away. If you want to email me, use my two initials,
+ Putting an actual email address here seems to have been a spam magnet,
+ so I've taken it away. If you want to email me, use my two initials,
followed by the two digits 10, at the domain cam.ac.uk.
REVISION
- Last updated: 24 August 2011
- Copyright (c) 1997-2011 University of Cambridge.
+ Last updated: 10 January 2012
+ Copyright (c) 1997-2012 University of Cambridge.
------------------------------------------------------------------------------
+
+
+PCRE(3) PCRE(3)
+
+
+NAME
+ PCRE - Perl-compatible regular expressions
+
+ #include <pcre.h>
+
+
+PCRE 16-BIT API BASIC FUNCTIONS
+
+ pcre16 *pcre16_compile(PCRE_SPTR16 pattern, int options,
+ const char **errptr, int *erroffset,
+ const unsigned char *tableptr);
+
+ pcre16 *pcre16_compile2(PCRE_SPTR16 pattern, int options,
+ int *errorcodeptr,
+ const char **errptr, int *erroffset,
+ const unsigned char *tableptr);
+
+ pcre16_extra *pcre16_study(const pcre16 *code, int options,
+ const char **errptr);
+
+ void pcre16_free_study(pcre16_extra *extra);
+
+ int pcre16_exec(const pcre16 *code, const pcre16_extra *extra,
+ PCRE_SPTR16 subject, int length, int startoffset,
+ int options, int *ovector, int ovecsize);
+
+ int pcre16_dfa_exec(const pcre16 *code, const pcre16_extra *extra,
+ PCRE_SPTR16 subject, int length, int startoffset,
+ int options, int *ovector, int ovecsize,
+ int *workspace, int wscount);
+
+
+PCRE 16-BIT API STRING EXTRACTION FUNCTIONS
+
+ int pcre16_copy_named_substring(const pcre16 *code,
+ PCRE_SPTR16 subject, int *ovector,
+ int stringcount, PCRE_SPTR16 stringname,
+ PCRE_UCHAR16 *buffer, int buffersize);
+
+ int pcre16_copy_substring(PCRE_SPTR16 subject, int *ovector,
+ int stringcount, int stringnumber, PCRE_UCHAR16 *buffer,
+ int buffersize);
+
+ int pcre16_get_named_substring(const pcre16 *code,
+ PCRE_SPTR16 subject, int *ovector,
+ int stringcount, PCRE_SPTR16 stringname,
+ PCRE_SPTR16 *stringptr);
+
+ int pcre16_get_stringnumber(const pcre16 *code,
+ PCRE_SPTR16 name);
+
+ int pcre16_get_stringtable_entries(const pcre16 *code,
+ PCRE_SPTR16 name, PCRE_UCHAR16 **first, PCRE_UCHAR16 **last);
+
+ int pcre16_get_substring(PCRE_SPTR16 subject, int *ovector,
+ int stringcount, int stringnumber,
+ PCRE_SPTR16 *stringptr);
+
+ int pcre16_get_substring_list(PCRE_SPTR16 subject,
+ int *ovector, int stringcount, PCRE_SPTR16 **listptr);
+
+ void pcre16_free_substring(PCRE_SPTR16 stringptr);
+
+ void pcre16_free_substring_list(PCRE_SPTR16 *stringptr);
+
+
+PCRE 16-BIT API AUXILIARY FUNCTIONS
+
+ pcre16_jit_stack *pcre16_jit_stack_alloc(int startsize, int maxsize);
+
+ void pcre16_jit_stack_free(pcre16_jit_stack *stack);
+
+ void pcre16_assign_jit_stack(pcre16_extra *extra,
+ pcre16_jit_callback callback, void *data);
+
+ const unsigned char *pcre16_maketables(void);
+
+ int pcre16_fullinfo(const pcre16 *code, const pcre16_extra *extra,
+ int what, void *where);
+
+ int pcre16_refcount(pcre16 *code, int adjust);
+
+ int pcre16_config(int what, void *where);
+
+ const char *pcre16_version(void);
+
+ int pcre16_pattern_to_host_byte_order(pcre16 *code,
+ pcre16_extra *extra, const unsigned char *tables);
+
+
+PCRE 16-BIT API INDIRECTED FUNCTIONS
+
+ void *(*pcre16_malloc)(size_t);
+
+ void (*pcre16_free)(void *);
+
+ void *(*pcre16_stack_malloc)(size_t);
+
+ void (*pcre16_stack_free)(void *);
+
+ int (*pcre16_callout)(pcre16_callout_block *);
+
+
+PCRE 16-BIT API 16-BIT-ONLY FUNCTION
+
+ int pcre16_utf16_to_host_byte_order(PCRE_UCHAR16 *output,
+ PCRE_SPTR16 input, int length, int *byte_order,
+ int keep_boms);
+
+
+THE PCRE 16-BIT LIBRARY
+
+ Starting with release 8.30, it is possible to compile a PCRE library
+ that supports 16-bit character strings, including UTF-16 strings, as
+ well as or instead of the original 8-bit library. The majority of the
+ work to make this possible was done by Zoltan Herczeg. The two
+ libraries contain identical sets of functions, used in exactly the same
+ way. Only the names of the functions and the data types of their argu-
+ ments and results are different. To avoid over-complication and reduce
+ the documentation maintenance load, most of the PCRE documentation
+ describes the 8-bit library, with only occasional references to the
+ 16-bit library. This page describes what is different when you use the
+ 16-bit library.
+
+ WARNING: A single application can be linked with both libraries, but
+ you must take care when processing any particular pattern to use func-
+ tions from just one library. For example, if you want to study a pat-
+ tern that was compiled with pcre16_compile(), you must do so with
+ pcre16_study(), not pcre_study(), and you must free the study data with
+ pcre16_free_study().
+
+
+THE HEADER FILE
+
+ There is only one header file, pcre.h. It contains prototypes for all
+ the functions in both libraries, as well as definitions of flags,
+ structures, error codes, etc.
+
+THE LIBRARY NAME
+ In Unix-like systems, the 16-bit library is called libpcre16, and can
+ normally be accesss by adding -lpcre16 to the command for linking an
+ application that uses PCRE.
+
+
+STRING TYPES
+
+ In the 8-bit library, strings are passed to PCRE library functions as
+ vectors of bytes with the C type "char *". In the 16-bit library,
+ strings are passed as vectors of unsigned 16-bit quantities. The macro
+ PCRE_UCHAR16 specifies an appropriate data type, and PCRE_SPTR16 is
+ defined as "const PCRE_UCHAR16 *". In very many environments, "short
+ int" is a 16-bit data type. When PCRE is built, it defines PCRE_UCHAR16
+ as "short int", but checks that it really is a 16-bit data type. If it
+ is not, the build fails with an error message telling the maintainer to
+ modify the definition appropriately.
+
+
+STRUCTURE TYPES
+
+ The types of the opaque structures that are used for compiled 16-bit
+ patterns and JIT stacks are pcre16 and pcre16_jit_stack respectively.
+ The type of the user-accessible structure that is returned by
+ pcre16_study() is pcre16_extra, and the type of the structure that is
+ used for passing data to a callout function is pcre16_callout_block.
+ These structures contain the same fields, with the same names, as their
+ 8-bit counterparts. The only difference is that pointers to character
+ strings are 16-bit instead of 8-bit types.
+
+
+16-BIT FUNCTIONS
+
+ For every function in the 8-bit library there is a corresponding func-
+ tion in the 16-bit library with a name that starts with pcre16_ instead
+ of pcre_. The prototypes are listed above. In addition, there is one
+ extra function, pcre16_utf16_to_host_byte_order(). This is a utility
+ function that converts a UTF-16 character string to host byte order if
+ necessary. The other 16-bit functions expect the strings they are
+ passed to be in host byte order.
+
+ The input and output arguments of pcre16_utf16_to_host_byte_order() may
+ point to the same address, that is, conversion in place is supported.
+ The output buffer must be at least as long as the input.
+
+ The length argument specifies the number of 16-bit data units in the
+ input string; a negative value specifies a zero-terminated string.
+
+ If byte_order is NULL, it is assumed that the string starts off in host
+ byte order. This may be changed by byte-order marks (BOMs) anywhere in
+ the string (commonly as the first character).
+
+ If byte_order is not NULL, a non-zero value of the integer to which it
+ points means that the input starts off in host byte order, otherwise
+ the opposite order is assumed. Again, BOMs in the string can change
+ this. The final byte order is passed back at the end of processing.
+
+ If keep_boms is not zero, byte-order mark characters (0xfeff) are
+ copied into the output string. Otherwise they are discarded.
+
+ The result of the function is the number of 16-bit units placed into
+ the output buffer, including the zero terminator if the string was
+ zero-terminated.
+
+
+SUBJECT STRING OFFSETS
+
+ The offsets within subject strings that are returned by the matching
+ functions are in 16-bit units rather than bytes.
+
+
+NAMED SUBPATTERNS
+
+ The name-to-number translation table that is maintained for named sub-
+ patterns uses 16-bit characters. The pcre16_get_stringtable_entries()
+ function returns the length of each entry in the table as the number of
+ 16-bit data units.
+
+
+OPTION NAMES
+
+ There are two new general option names, PCRE_UTF16 and
+ PCRE_NO_UTF16_CHECK, which correspond to PCRE_UTF8 and
+ PCRE_NO_UTF8_CHECK in the 8-bit library. In fact, these new options
+ define the same bits in the options word.
+
+ For the pcre16_config() function there is an option PCRE_CONFIG_UTF16
+ that returns 1 if UTF-16 support is configured, otherwise 0. If this
+ option is given to pcre_config(), or if the PCRE_CONFIG_UTF8 option is
+ given to pcre16_config(), the result is the PCRE_ERROR_BADOPTION error.
+
+
+CHARACTER CODES
+
+ In 16-bit mode, when PCRE_UTF16 is not set, character values are
+ treated in the same way as in 8-bit, non UTF-8 mode, except, of course,
+ that they can range from 0 to 0xffff instead of 0 to 0xff. Character
+ types for characters less than 0xff can therefore be influenced by the
+ locale in the same way as before. Characters greater than 0xff have
+ only one case, and no "type" (such as letter or digit).
+
+ In UTF-16 mode, the character code is Unicode, in the range 0 to
+ 0x10ffff, with the exception of values in the range 0xd800 to 0xdfff
+ because those are "surrogate" values that are used in pairs to encode
+ values greater than 0xffff.
+
+ A UTF-16 string can indicate its endianness by special code knows as a
+ byte-order mark (BOM). The PCRE functions do not handle this, expecting
+ strings to be in host byte order. A utility function called
+ pcre16_utf16_to_host_byte_order() is provided to help with this (see
+ above).
+
+
+ERROR NAMES
+
+ The errors PCRE_ERROR_BADUTF16_OFFSET and PCRE_ERROR_SHORTUTF16 corre-
+ spond to their 8-bit counterparts. The error PCRE_ERROR_BADMODE is
+ given when a compiled pattern is passed to a function that processes
+ patterns in the other mode, for example, if a pattern compiled with
+ pcre_compile() is passed to pcre16_exec().
+
+ There are new error codes whose names begin with PCRE_UTF16_ERR for
+ invalid UTF-16 strings, corresponding to the PCRE_UTF8_ERR codes for
+ UTF-8 strings that are described in the section entitled "Reason codes
+ for invalid UTF-8 strings" in the main pcreapi page. The UTF-16 errors
+ are:
+
+ PCRE_UTF16_ERR1 Missing low surrogate at end of string
+ PCRE_UTF16_ERR2 Invalid low surrogate follows high surrogate
+ PCRE_UTF16_ERR3 Isolated low surrogate
+ PCRE_UTF16_ERR4 Invalid character 0xfffe
+
+
+ERROR TEXTS
+
+ If there is an error while compiling a pattern, the error text that is
+ passed back by pcre16_compile() or pcre16_compile2() is still an 8-bit
+ character string, zero-terminated.
+
+
+CALLOUTS
+
+ The subject and mark fields in the callout block that is passed to a
+ callout function point to 16-bit vectors.
+
+
+TESTING
+
+ The pcretest program continues to operate with 8-bit input and output
+ files, but it can be used for testing the 16-bit library. If it is run
+ with the command line option -16, patterns and subject strings are con-
+ verted from 8-bit to 16-bit before being passed to PCRE, and the 16-bit
+ library functions are used instead of the 8-bit ones. Returned 16-bit
+ strings are converted to 8-bit for output. If the 8-bit library was not
+ compiled, pcretest defaults to 16-bit and the -16 option is ignored.
+
+ When PCRE is being built, the RunTest script that is called by "make
+ check" uses the pcretest -C option to discover which of the 8-bit and
+ 16-bit libraries has been built, and runs the tests appropriately.
+
+
+NOT SUPPORTED IN 16-BIT MODE
+
+ Not all the features of the 8-bit library are available with the 16-bit
+ library. The C++ and POSIX wrapper functions support only the 8-bit
+ library, and the pcregrep program is at present 8-bit only.
+
+
+AUTHOR
+
+ Philip Hazel
+ University Computing Service
+ Cambridge CB2 3QH, England.
+
+
+REVISION
+
+ Last updated: 08 January 2012
+ Copyright (c) 1997-2012 University of Cambridge.
+------------------------------------------------------------------------------
+
+
PCREBUILD(3) PCREBUILD(3)
@@ -158,6 +501,27 @@ PCRE BUILD-TIME OPTIONS
is not described.
+BUILDING 8-BIT and 16-BIT LIBRARIES
+
+ By default, a library called libpcre is built, containing functions
+ that take string arguments contained in vectors of bytes, either as
+ single-byte characters, or interpreted as UTF-8 strings. You can also
+ build a separate library, called libpcre16, in which strings are con-
+ tained in vectors of 16-bit data units and interpreted either as sin-
+ gle-unit characters or UTF-16 strings, by adding
+
+ --enable-pcre16
+
+ to the configure command. If you do not want the 8-bit library, add
+
+ --disable-pcre8
+
+ as well. At least one of the two libraries must be built. Note that the
+ C++ and POSIX wrappers are for the 8-bit library only, and that pcre-
+ grep is an 8-bit program. None of these are built if you select only
+ the 16-bit library.
+
+
BUILDING SHARED AND STATIC LIBRARIES
The PCRE building process uses libtool to build both shared and static
@@ -172,48 +536,55 @@ BUILDING SHARED AND STATIC LIBRARIES
C++ SUPPORT
- By default, the configure script will search for a C++ compiler and C++
- header files. If it finds them, it automatically builds the C++ wrapper
- library for PCRE. You can disable this by adding
+ By default, if the 8-bit library is being built, the configure script
+ will search for a C++ compiler and C++ header files. If it finds them,
+ it automatically builds the C++ wrapper library (which supports only
+ 8-bit strings). You can disable this by adding
--disable-cpp
to the configure command.
-UTF-8 SUPPORT
+UTF-8 and UTF-16 SUPPORT
+
+ To build PCRE with support for UTF Unicode character strings, add
- To build PCRE with support for UTF-8 Unicode character strings, add
+ --enable-utf
- --enable-utf8
+ to the configure command. This setting applies to both libraries,
+ adding support for UTF-8 to the 8-bit library and support for UTF-16 to
+ the 16-bit library. It is not possible to build one library with UTF
+ support and the other without in the same configuration. (For backwards
+ compatibility, --enable-utf8 is a synonym of --enable-utf.)
- to the configure command. Of itself, this does not make PCRE treat
- strings as UTF-8. As well as compiling PCRE with this option, you also
- have have to set the PCRE_UTF8 option when you call the pcre_compile()
- or pcre_compile2() functions.
+ Of itself, this setting does not make PCRE treat strings as UTF-8 or
+ UTF-16. As well as compiling PCRE with this option, you also have have
+ to set the PCRE_UTF8 or PCRE_UTF16 option when you call one of the pat-
+ tern compiling functions.
- If you set --enable-utf8 when compiling in an EBCDIC environment, PCRE
+ If you set --enable-utf when compiling in an EBCDIC environment, PCRE
expects its input to be either ASCII or UTF-8 (depending on the runtime
- option). It is not possible to support both EBCDIC and UTF-8 codes in
- the same version of the library. Consequently, --enable-utf8 and
+ option). It is not possible to support both EBCDIC and UTF-8 codes in
+ the same version of the library. Consequently, --enable-utf and
--enable-ebcdic are mutually exclusive.
UNICODE CHARACTER PROPERTY SUPPORT
- UTF-8 support allows PCRE to process character values greater than 255
- in the strings that it handles. On its own, however, it does not pro-
- vide any facilities for accessing the properties of such characters. If
- you want to be able to use the pattern escapes \P, \p, and \X, which
- refer to Unicode character properties, you must add
+ UTF support allows the libraries to process character codepoints up to
+ 0x10ffff in the strings that they handle. On its own, however, it does
+ not provide any facilities for accessing the properties of such charac-
+ ters. If you want to be able to use the pattern escapes \P, \p, and \X,
+ which refer to Unicode character properties, you must add
--enable-unicode-properties
- to the configure command. This implies UTF-8 support, even if you have
+ to the configure command. This implies UTF support, even if you have
not explicitly requested it.
- Including Unicode property support adds around 30K of tables to the
- PCRE library. Only the general category properties such as Lu and Nd
+ Including Unicode property support adds around 30K of tables to the
+ PCRE library. Only the general category properties such as Lu and Nd
are supported. Details are given in the pcrepattern documentation.
@@ -223,9 +594,9 @@ JUST-IN-TIME COMPILER SUPPORT
--enable-jit
- This support is available only for certain hardware architectures. If
- this option is set for an unsupported architecture, a compile time
- error occurs. See the pcrejit documentation for a discussion of JIT
+ This support is available only for certain hardware architectures. If
+ this option is set for an unsupported architecture, a compile time
+ error occurs. See the pcrejit documentation for a discussion of JIT
usage. When JIT support is enabled, pcregrep automatically makes use of
it, unless you add
@@ -236,14 +607,14 @@ JUST-IN-TIME COMPILER SUPPORT
CODE VALUE OF NEWLINE
- By default, PCRE interprets the linefeed (LF) character as indicating
- the end of a line. This is the normal newline character on Unix-like
- systems. You can compile PCRE to use carriage return (CR) instead, by
+ By default, PCRE interprets the linefeed (LF) character as indicating
+ the end of a line. This is the normal newline character on Unix-like
+ systems. You can compile PCRE to use carriage return (CR) instead, by
adding
--enable-newline-is-cr
- to the configure command. There is also a --enable-newline-is-lf
+ to the configure command. There is also a --enable-newline-is-lf
option, which explicitly specifies linefeed as the newline character.
Alternatively, you can specify that line endings are to be indicated by
@@ -255,41 +626,41 @@ CODE VALUE OF NEWLINE
--enable-newline-is-anycrlf
- which causes PCRE to recognize any of the three sequences CR, LF, or
+ which causes PCRE to recognize any of the three sequences CR, LF, or
CRLF as indicating a line ending. Finally, a fifth option, specified by
--enable-newline-is-any
causes PCRE to recognize any Unicode newline sequence.
- Whatever line ending convention is selected when PCRE is built can be
- overridden when the library functions are called. At build time it is
+ Whatever line ending convention is selected when PCRE is built can be
+ overridden when the library functions are called. At build time it is
conventional to use the standard for your operating system.
WHAT \R MATCHES
- By default, the sequence \R in a pattern matches any Unicode newline
- sequence, whatever has been selected as the line ending sequence. If
+ By default, the sequence \R in a pattern matches any Unicode newline
+ sequence, whatever has been selected as the line ending sequence. If
you specify
--enable-bsr-anycrlf
- the default is changed so that \R matches only CR, LF, or CRLF. What-
- ever is selected when PCRE is built can be overridden when the library
+ the default is changed so that \R matches only CR, LF, or CRLF. What-
+ ever is selected when PCRE is built can be overridden when the library
functions are called.
POSIX MALLOC USAGE
- When PCRE is called through the POSIX interface (see the pcreposix doc-
- umentation), additional working storage is required for holding the
- pointers to capturing substrings, because PCRE requires three integers
- per substring, whereas the POSIX interface provides only two. If the
- number of expected substrings is small, the wrapper function uses space
- on the stack, because this is faster than using malloc() for each call.
- The default threshold above which the stack is no longer used is 10; it
- can be changed by adding a setting such as
+ When the 8-bit library is called through the POSIX interface (see the
+ pcreposix documentation), additional working storage is required for
+ holding the pointers to capturing substrings, because PCRE requires
+ three integers per substring, whereas the POSIX interface provides only
+ two. If the number of expected substrings is small, the wrapper func-
+ tion uses space on the stack, because this is faster than using mal-
+ loc() for each call. The default threshold above which the stack is no
+ longer used is 10; it can be changed by adding a setting such as
--with-posix-malloc-threshold=20
@@ -298,20 +669,21 @@ POSIX MALLOC USAGE
HANDLING VERY LARGE PATTERNS
- Within a compiled pattern, offset values are used to point from one
- part to another (for example, from an opening parenthesis to an alter-
- nation metacharacter). By default, two-byte values are used for these
- offsets, leading to a maximum size for a compiled pattern of around
- 64K. This is sufficient to handle all but the most gigantic patterns.
- Nevertheless, some people do want to process truyl enormous patterns,
- so it is possible to compile PCRE to use three-byte or four-byte off-
+ Within a compiled pattern, offset values are used to point from one
+ part to another (for example, from an opening parenthesis to an alter-
+ nation metacharacter). By default, two-byte values are used for these
+ offsets, leading to a maximum size for a compiled pattern of around
+ 64K. This is sufficient to handle all but the most gigantic patterns.
+ Nevertheless, some people do want to process truly enormous patterns,
+ so it is possible to compile PCRE to use three-byte or four-byte off-
sets by adding a setting such as
--with-link-size=3
- to the configure command. The value given must be 2, 3, or 4. Using
- longer offsets slows down the operation of PCRE because it has to load
- additional bytes when handling them.
+ to the configure command. The value given must be 2, 3, or 4. For the
+ 16-bit library, a value of 3 is rounded up to 4. Using longer offsets
+ slows down the operation of PCRE because it has to load additional data
+ when handling them.
AVOIDING EXCESSIVE STACK USAGE
@@ -403,7 +775,7 @@ USING EBCDIC CODE
to the configure command. This setting implies --enable-rebuild-charta-
bles. You should only use it if you know that you are in an EBCDIC
environment (for example, an IBM mainframe operating system). The
- --enable-ebcdic option is incompatible with --enable-utf8.
+ --enable-ebcdic option is incompatible with --enable-utf.
PCREGREP OPTIONS FOR COMPRESSED FILE SUPPORT
@@ -469,7 +841,7 @@ PCRETEST OPTION FOR LIBREADLINE SUPPORT
SEE ALSO
- pcreapi(3), pcre_config(3).
+ pcreapi(3), pcre16, pcre_config(3).
AUTHOR
@@ -481,11 +853,11 @@ AUTHOR
REVISION
- Last updated: 06 September 2011
- Copyright (c) 1997-2011 University of Cambridge.
+ Last updated: 07 January 2012
+ Copyright (c) 1997-2012 University of Cambridge.
------------------------------------------------------------------------------
-
-
+
+
PCREMATCHING(3) PCREMATCHING(3)
@@ -498,13 +870,15 @@ PCRE MATCHING ALGORITHMS
This document describes the two different algorithms that are available
in PCRE for matching a compiled regular expression against a given sub-
ject string. The "standard" algorithm is the one provided by the
- pcre_exec() function. This works in the same was as Perl's matching
- function, and provides a Perl-compatible matching operation.
+ pcre_exec() and pcre16_exec() functions. These work in the same was as
+ Perl's matching function, and provide a Perl-compatible matching opera-
+ tion. The just-in-time (JIT) optimization that is described in the
+ pcrejit documentation is compatible with these functions.
- An alternative algorithm is provided by the pcre_dfa_exec() function;
- this operates in a different way, and is not Perl-compatible. It has
- advantages and disadvantages compared with the standard algorithm, and
- these are described below.
+ An alternative algorithm is provided by the pcre_dfa_exec() and
+ pcre16_dfa_exec() functions; they operate in a different way, and are
+ not Perl-compatible. This alternative has advantages and disadvantages
+ compared with the standard algorithm, and these are described below.
When there is only one possible way in which a given subject string can
match a pattern, the two algorithms give the same answer. A difference
@@ -632,42 +1006,43 @@ THE ALTERNATIVE MATCHING ALGORITHM
6. Callouts are supported, but the value of the capture_top field is
always 1, and the value of the capture_last field is always -1.
- 7. The \C escape sequence, which (in the standard algorithm) matches a
- single byte, even in UTF-8 mode, is not supported in UTF-8 mode,
- because the alternative algorithm moves through the subject string one
- character at a time, for all active paths through the tree.
+ 7. The \C escape sequence, which (in the standard algorithm) always
+ matches a single data unit, even in UTF-8 or UTF-16 modes, is not sup-
+ ported in these modes, because the alternative algorithm moves through
+ the subject string one character (not data unit) at a time, for all
+ active paths through the tree.
- 8. Except for (*FAIL), the backtracking control verbs such as (*PRUNE)
- are not supported. (*FAIL) is supported, and behaves like a failing
+ 8. Except for (*FAIL), the backtracking control verbs such as (*PRUNE)
+ are not supported. (*FAIL) is supported, and behaves like a failing
negative assertion.
ADVANTAGES OF THE ALTERNATIVE ALGORITHM
- Using the alternative matching algorithm provides the following advan-
+ Using the alternative matching algorithm provides the following advan-
tages:
1. All possible matches (at a single point in the subject) are automat-
- ically found, and in particular, the longest match is found. To find
+ ically found, and in particular, the longest match is found. To find
more than one match using the standard algorithm, you have to do kludgy
things with callouts.
- 2. Because the alternative algorithm scans the subject string just
- once, and never needs to backtrack, it is possible to pass very long
- subject strings to the matching function in several pieces, checking
- for partial matching each time. Although it is possible to do multi-
- segment matching using the standard algorithm (pcre_exec()), by retain-
- ing partially matched substrings, it is more complicated. The pcrepar-
- tial documentation gives details of partial matching and discusses
- multi-segment matching.
+ 2. Because the alternative algorithm scans the subject string just
+ once, and never needs to backtrack (except for lookbehinds), it is pos-
+ sible to pass very long subject strings to the matching function in
+ several pieces, checking for partial matching each time. Although it is
+ possible to do multi-segment matching using the standard algorithm by
+ retaining partially matched substrings, it is more complicated. The
+ pcrepartial documentation gives details of partial matching and dis-
+ cusses multi-segment matching.
DISADVANTAGES OF THE ALTERNATIVE ALGORITHM
The alternative algorithm suffers from a number of disadvantages:
- 1. It is substantially slower than the standard algorithm. This is
- partly because it has to search for all possible matches, but is also
+ 1. It is substantially slower than the standard algorithm. This is
+ partly because it has to search for all possible matches, but is also
because it is less susceptible to optimization.
2. Capturing parentheses and back references are not supported.
@@ -685,21 +1060,21 @@ AUTHOR
REVISION
- Last updated: 19 November 2011
- Copyright (c) 1997-2010 University of Cambridge.
+ Last updated: 08 January 2012
+ Copyright (c) 1997-2012 University of Cambridge.
------------------------------------------------------------------------------
-
-
+
+
PCREAPI(3) PCREAPI(3)
NAME
PCRE - Perl-compatible regular expressions
+ #include <pcre.h>
-PCRE NATIVE API BASIC FUNCTIONS
- #include <pcre.h>
+PCRE NATIVE API BASIC FUNCTIONS
pcre *pcre_compile(const char *pattern, int options,
const char **errptr, int *erroffset,
@@ -719,21 +1094,14 @@ PCRE NATIVE API BASIC FUNCTIONS
const char *subject, int length, int startoffset,
int options, int *ovector, int ovecsize);
-
-PCRE NATIVE API AUXILIARY FUNCTIONS
-
- pcre_jit_stack *pcre_jit_stack_alloc(int startsize, int maxsize);
-
- void pcre_jit_stack_free(pcre_jit_stack *stack);
-
- void pcre_assign_jit_stack(pcre_extra *extra,
- pcre_jit_callback callback, void *data);
-
int pcre_dfa_exec(const pcre *code, const pcre_extra *extra,
const char *subject, int length, int startoffset,
int options, int *ovector, int ovecsize,
int *workspace, int wscount);
+
+PCRE NATIVE API STRING EXTRACTION FUNCTIONS
+
int pcre_copy_named_substring(const pcre *code,
const char *subject, int *ovector,
int stringcount, const char *stringname,
@@ -765,18 +1133,29 @@ PCRE NATIVE API AUXILIARY FUNCTIONS
void pcre_free_substring_list(const char **stringptr);
+
+PCRE NATIVE API AUXILIARY FUNCTIONS
+
+ pcre_jit_stack *pcre_jit_stack_alloc(int startsize, int maxsize);
+
+ void pcre_jit_stack_free(pcre_jit_stack *stack);
+
+ void pcre_assign_jit_stack(pcre_extra *extra,
+ pcre_jit_callback callback, void *data);
+
const unsigned char *pcre_maketables(void);
int pcre_fullinfo(const pcre *code, const pcre_extra *extra,
int what, void *where);
- int pcre_info(const pcre *code, int *optptr, int *firstcharptr);
-
int pcre_refcount(pcre *code, int adjust);
int pcre_config(int what, void *where);
- char *pcre_version(void);
+ const char *pcre_version(void);
+
+ int pcre_pattern_to_host_byte_order(pcre *code,
+ pcre_extra *extra, const unsigned char *tables);
PCRE NATIVE API INDIRECTED FUNCTIONS
@@ -792,21 +1171,44 @@ PCRE NATIVE API INDIRECTED FUNCTIONS
int (*pcre_callout)(pcre_callout_block *);
+PCRE 8-BIT AND 16-BIT LIBRARIES
+
+ From release 8.30, PCRE can be compiled as a library for handling
+ 16-bit character strings as well as, or instead of, the original
+ library that handles 8-bit character strings. To avoid too much compli-
+ cation, this document describes the 8-bit versions of the functions,
+ with only occasional references to the 16-bit library.
+
+ The 16-bit functions operate in the same way as their 8-bit counter-
+ parts; they just use different data types for their arguments and
+ results, and their names start with pcre16_ instead of pcre_. For every
+ option that has UTF8 in its name (for example, PCRE_UTF8), there is a
+ corresponding 16-bit name with UTF8 replaced by UTF16. This facility is
+ in fact just cosmetic; the 16-bit option names define the same bit val-
+ ues.
+
+ References to bytes and UTF-8 in this document should be read as refer-
+ ences to 16-bit data quantities and UTF-16 when using the 16-bit
+ library, unless specified otherwise. More details of the specific dif-
+ ferences for the 16-bit library are given in the pcre16 page.
+
+
PCRE API OVERVIEW
PCRE has its own native API, which is described in this document. There
- are also some wrapper functions that correspond to the POSIX regular
- expression API, but they do not give access to all the functionality.
- They are described in the pcreposix documentation. Both of these APIs
- define a set of C function calls. A C++ wrapper is also distributed
- with PCRE. It is documented in the pcrecpp page.
+ are also some wrapper functions (for the 8-bit library only) that cor-
+ respond to the POSIX regular expression API, but they do not give
+ access to all the functionality. They are described in the pcreposix
+ documentation. Both of these APIs define a set of C function calls. A
+ C++ wrapper (again for the 8-bit library only) is also distributed with
+ PCRE. It is documented in the pcrecpp page.
The native API C function prototypes are defined in the header file
- pcre.h, and on Unix systems the library itself is called libpcre. It
- can normally be accessed by adding -lpcre to the command for linking an
- application that uses PCRE. The header file defines the macros
- PCRE_MAJOR and PCRE_MINOR to contain the major and minor release num-
- bers for the library. Applications can use these to include support
+ pcre.h, and on Unix-like systems the (8-bit) library itself is called
+ libpcre. It can normally be accessed by adding -lpcre to the command
+ for linking an application that uses PCRE. The header file defines the
+ macros PCRE_MAJOR and PCRE_MINOR to contain the major and minor release
+ numbers for the library. Applications can use these to include support
for different releases of PCRE.
In a Windows environment, if you want to statically link an application
@@ -865,10 +1267,8 @@ PCRE API OVERVIEW
built are used.
The function pcre_fullinfo() is used to find out information about a
- compiled pattern; pcre_info() is an obsolete version that returns only
- some of the available information, but is retained for backwards com-
- patibility. The function pcre_version() returns a pointer to a string
- containing the version of PCRE and its date of release.
+ compiled pattern. The function pcre_version() returns a pointer to a
+ string containing the version of PCRE and its date of release.
The function pcre_refcount() maintains a reference count in a data
block containing a compiled pattern. This is provided for the benefit
@@ -955,33 +1355,46 @@ SAVING PRECOMPILED PATTERNS FOR LATER USE
The compiled form of a regular expression can be saved and re-used at a
later time, possibly by a different program, and even on a host other
than the one on which it was compiled. Details are given in the
- pcreprecompile documentation. However, compiling a regular expression
- with one version of PCRE for use with a different version is not guar-
- anteed to work and may cause crashes.
+ pcreprecompile documentation, which includes a description of the
+ pcre_pattern_to_host_byte_order() function. However, compiling a regu-
+ lar expression with one version of PCRE for use with a different ver-
+ sion is not guaranteed to work and may cause crashes.
CHECKING BUILD-TIME OPTIONS
int pcre_config(int what, void *where);
- The function pcre_config() makes it possible for a PCRE client to dis-
+ The function pcre_config() makes it possible for a PCRE client to dis-
cover which optional features have been compiled into the PCRE library.
- The pcrebuild documentation has more details about these optional fea-
+ The pcrebuild documentation has more details about these optional fea-
tures.
- The first argument for pcre_config() is an integer, specifying which
+ The first argument for pcre_config() is an integer, specifying which
information is required; the second argument is a pointer to a variable
- into which the information is placed. The following information is
+ into which the information is placed. The returned value is zero on
+ success, or the negative error code PCRE_ERROR_BADOPTION if the value
+ in the first argument is not recognized. The following information is
available:
PCRE_CONFIG_UTF8
- The output is an integer that is set to one if UTF-8 support is avail-
- able; otherwise it is set to zero.
+ The output is an integer that is set to one if UTF-8 support is avail-
+ able; otherwise it is set to zero. If this option is given to the
+ 16-bit version of this function, pcre16_config(), the result is
+ PCRE_ERROR_BADOPTION.
+
+ PCRE_CONFIG_UTF16
+
+ The output is an integer that is set to one if UTF-16 support is avail-
+ able; otherwise it is set to zero. This value should normally be given
+ to the 16-bit version of this function, pcre16_config(). If it is given
+ to the 8-bit version of this function, the result is PCRE_ERROR_BADOP-
+ TION.
PCRE_CONFIG_UNICODE_PROPERTIES
- The output is an integer that is set to one if support for Unicode
+ The output is an integer that is set to one if support for Unicode
character properties is available; otherwise it is set to zero.
PCRE_CONFIG_JIT
@@ -991,57 +1404,59 @@ CHECKING BUILD-TIME OPTIONS
PCRE_CONFIG_NEWLINE
- The output is an integer whose value specifies the default character
- sequence that is recognized as meaning "newline". The four values that
+ The output is an integer whose value specifies the default character
+ sequence that is recognized as meaning "newline". The four values that
are supported are: 10 for LF, 13 for CR, 3338 for CRLF, -2 for ANYCRLF,
- and -1 for ANY. Though they are derived from ASCII, the same values
+ and -1 for ANY. Though they are derived from ASCII, the same values
are returned in EBCDIC environments. The default should normally corre-
spond to the standard sequence for your operating system.
PCRE_CONFIG_BSR
The output is an integer whose value indicates what character sequences
- the \R escape sequence matches by default. A value of 0 means that \R
- matches any Unicode line ending sequence; a value of 1 means that \R
+ the \R escape sequence matches by default. A value of 0 means that \R
+ matches any Unicode line ending sequence; a value of 1 means that \R
matches only CR, LF, or CRLF. The default can be overridden when a pat-
tern is compiled or matched.
PCRE_CONFIG_LINK_SIZE
- The output is an integer that contains the number of bytes used for
- internal linkage in compiled regular expressions. The value is 2, 3, or
- 4. Larger values allow larger regular expressions to be compiled, at
- the expense of slower matching. The default value of 2 is sufficient
- for all but the most massive patterns, since it allows the compiled
- pattern to be up to 64K in size.
+ The output is an integer that contains the number of bytes used for
+ internal linkage in compiled regular expressions. For the 8-bit
+ library, the value can be 2, 3, or 4. For the 16-bit library, the value
+ is either 2 or 4 and is still a number of bytes. The default value of 2
+ is sufficient for all but the most massive patterns, since it allows
+ the compiled pattern to be up to 64K in size. Larger values allow
+ larger regular expressions to be compiled, at the expense of slower
+ matching.
PCRE_CONFIG_POSIX_MALLOC_THRESHOLD
- The output is an integer that contains the threshold above which the
- POSIX interface uses malloc() for output vectors. Further details are
+ The output is an integer that contains the threshold above which the
+ POSIX interface uses malloc() for output vectors. Further details are
given in the pcreposix documentation.
PCRE_CONFIG_MATCH_LIMIT
- The output is a long integer that gives the default limit for the num-
- ber of internal matching function calls in a pcre_exec() execution.
+ The output is a long integer that gives the default limit for the num-
+ ber of internal matching function calls in a pcre_exec() execution.
Further details are given with pcre_exec() below.
PCRE_CONFIG_MATCH_LIMIT_RECURSION
The output is a long integer that gives the default limit for the depth
- of recursion when calling the internal matching function in a
- pcre_exec() execution. Further details are given with pcre_exec()
+ of recursion when calling the internal matching function in a
+ pcre_exec() execution. Further details are given with pcre_exec()
below.
PCRE_CONFIG_STACKRECURSE
- The output is an integer that is set to one if internal recursion when
+ The output is an integer that is set to one if internal recursion when
running pcre_exec() is implemented by recursive function calls that use
- the stack to remember their state. This is the usual way that PCRE is
+ the stack to remember their state. This is the usual way that PCRE is
compiled. The output is zero if PCRE was compiled to use blocks of data
- on the heap instead of recursive function calls. In this case,
- pcre_stack_malloc and pcre_stack_free are called to manage memory
+ on the heap instead of recursive function calls. In this case,
+ pcre_stack_malloc and pcre_stack_free are called to manage memory
blocks on the heap, thus avoiding the use of the stack.
@@ -1058,49 +1473,48 @@ COMPILING A PATTERN
Either of the functions pcre_compile() or pcre_compile2() can be called
to compile a pattern into an internal form. The only difference between
- the two interfaces is that pcre_compile2() has an additional argument,
- errorcodeptr, via which a numerical error code can be returned. To
- avoid too much repetition, we refer just to pcre_compile() below, but
+ the two interfaces is that pcre_compile2() has an additional argument,
+ errorcodeptr, via which a numerical error code can be returned. To
+ avoid too much repetition, we refer just to pcre_compile() below, but
the information applies equally to pcre_compile2().
The pattern is a C string terminated by a binary zero, and is passed in
- the pattern argument. A pointer to a single block of memory that is
- obtained via pcre_malloc is returned. This contains the compiled code
+ the pattern argument. A pointer to a single block of memory that is
+ obtained via pcre_malloc is returned. This contains the compiled code
and related data. The pcre type is defined for the returned block; this
is a typedef for a structure whose contents are not externally defined.
It is up to the caller to free the memory (via pcre_free) when it is no
longer required.
- Although the compiled code of a PCRE regex is relocatable, that is, it
+ Although the compiled code of a PCRE regex is relocatable, that is, it
does not depend on memory location, the complete pcre data block is not
- fully relocatable, because it may contain a copy of the tableptr argu-
+ fully relocatable, because it may contain a copy of the tableptr argu-
ment, which is an address (see below).
The options argument contains various bit settings that affect the com-
- pilation. It should be zero if no options are required. The available
- options are described below. Some of them (in particular, those that
- are compatible with Perl, but some others as well) can also be set and
- unset from within the pattern (see the detailed description in the
- pcrepattern documentation). For those options that can be different in
- different parts of the pattern, the contents of the options argument
+ pilation. It should be zero if no options are required. The available
+ options are described below. Some of them (in particular, those that
+ are compatible with Perl, but some others as well) can also be set and
+ unset from within the pattern (see the detailed description in the
+ pcrepattern documentation). For those options that can be different in
+ different parts of the pattern, the contents of the options argument
specifies their settings at the start of compilation and execution. The
- PCRE_ANCHORED, PCRE_BSR_xxx, PCRE_NEWLINE_xxx, PCRE_NO_UTF8_CHECK, and
+ PCRE_ANCHORED, PCRE_BSR_xxx, PCRE_NEWLINE_xxx, PCRE_NO_UTF8_CHECK, and
PCRE_NO_START_OPT options can be set at the time of matching as well as
at compile time.
If errptr is NULL, pcre_compile() returns NULL immediately. Otherwise,
- if compilation of a pattern fails, pcre_compile() returns NULL, and
+ if compilation of a pattern fails, pcre_compile() returns NULL, and
sets the variable pointed to by errptr to point to a textual error mes-
sage. This is a static string that is part of the library. You must not
- try to free it. Normally, the offset from the start of the pattern to
- the byte that was being processed when the error was discovered is
- placed in the variable pointed to by erroffset, which must not be NULL
- (if it is, an immediate error is given). However, for an invalid UTF-8
- string, the offset is that of the first byte of the failing character.
- Also, some errors are not detected until checks are carried out when
- the whole pattern has been scanned; in these cases the offset passed
- back is the length of the pattern.
-
+ try to free it. Normally, the offset from the start of the pattern to
+ the byte that was being processed when the error was discovered is
+ placed in the variable pointed to by erroffset, which must not be NULL
+ (if it is, an immediate error is given). However, for an invalid UTF-8
+ string, the offset is that of the first byte of the failing character.
+
+ Some errors are not detected until the whole pattern has been scanned;
+ in these cases, the offset passed back is the length of the pattern.
Note that the offset is in bytes, not characters, even in UTF-8 mode.
It may sometimes point into the middle of a UTF-8 character.
@@ -1303,8 +1717,8 @@ COMPILING A PATTERN
recognized. The Unicode newline sequences are the three just mentioned,
plus the single characters VT (vertical tab, U+000B), FF (formfeed,
U+000C), NEL (next line, U+0085), LS (line separator, U+2028), and PS
- (paragraph separator, U+2029). The last two are recognized only in
- UTF-8 mode.
+ (paragraph separator, U+2029). For the 8-bit library, the last two are
+ recognized only in UTF-8 mode.
The newline setting in the options word uses three bits that are
treated as a number, giving eight possibilities. Currently only six are
@@ -1361,32 +1775,33 @@ COMPILING A PATTERN
PCRE_UTF8
This option causes PCRE to regard both the pattern and the subject as
- strings of UTF-8 characters instead of single-byte character strings.
- However, it is available only when PCRE is built to include UTF-8 sup-
- port. If not, the use of this option provokes an error. Details of how
- this option changes the behaviour of PCRE are given in the pcreunicode
- page.
+ strings of UTF-8 characters instead of single-byte strings. However, it
+ is available only when PCRE is built to include UTF support. If not,
+ the use of this option provokes an error. Details of how this option
+ changes the behaviour of PCRE are given in the pcreunicode page.
PCRE_NO_UTF8_CHECK
When PCRE_UTF8 is set, the validity of the pattern as a UTF-8 string is
- automatically checked. There is a discussion about the validity of
- UTF-8 strings in the main pcre page. If an invalid UTF-8 sequence of
- bytes is found, pcre_compile() returns an error. If you already know
- that your pattern is valid, and you want to skip this check for perfor-
- mance reasons, you can set the PCRE_NO_UTF8_CHECK option. When it is
- set, the effect of passing an invalid UTF-8 string as a pattern is
- undefined. It may cause your program to crash. Note that this option
- can also be passed to pcre_exec() and pcre_dfa_exec(), to suppress the
- UTF-8 validity checking of subject strings.
+ automatically checked. There is a discussion about the validity of
+ UTF-8 strings in the pcreunicode page. If an invalid UTF-8 sequence is
+ found, pcre_compile() returns an error. If you already know that your
+ pattern is valid, and you want to skip this check for performance rea-
+ sons, you can set the PCRE_NO_UTF8_CHECK option. When it is set, the
+ effect of passing an invalid UTF-8 string as a pattern is undefined. It
+ may cause your program to crash. Note that this option can also be
+ passed to pcre_exec() and pcre_dfa_exec(), to suppress the validity
+ checking of subject strings.
COMPILATION ERROR CODES
- The following table lists the error codes than may be returned by
- pcre_compile2(), along with the error messages that may be returned by
- both compiling functions. As PCRE has developed, some error codes have
- fallen out of use. To avoid confusion, they have not been re-used.
+ The following table lists the error codes than may be returned by
+ pcre_compile2(), along with the error messages that may be returned by
+ both compiling functions. Note that error messages are always 8-bit
+ ASCII strings, even in 16-bit mode. As PCRE has developed, some error
+ codes have fallen out of use. To avoid confusion, they have not been
+ re-used.
0 no error
1 \ at end of pattern
@@ -1420,7 +1835,7 @@ COMPILATION ERROR CODES
29 (?R or (?[+-]digits must be followed by )
30 unknown POSIX class name
31 POSIX collating elements are not supported
- 32 this version of PCRE is not compiled with PCRE_UTF8 support
+ 32 this version of PCRE is compiled without UTF support
33 [this code is not in use]
34 character value in \x{...} sequence is too large
35 invalid condition (?(0)
@@ -1432,14 +1847,14 @@ COMPILATION ERROR CODES
41 unrecognized character after (?P
42 syntax error in subpattern name (missing terminator)
43 two named subpatterns have the same name
- 44 invalid UTF-8 string
+ 44 invalid UTF-8 string (specifically UTF-8)
45 support for \P, \p, and \X has not been compiled
46 malformed \P or \p sequence
47 unknown property name after \P or \p
48 subpattern name is too long (maximum 32 characters)
49 too many named subpatterns (maximum 10000)
50 [this code is not in use]
- 51 octal value is greater than \377 (not in UTF-8 mode)
+ 51 octal value is greater than \377 in 8-bit non-UTF-8 mode
52 internal error: overran compiling workspace
53 internal error: previously-checked referenced subpattern
not found
@@ -1458,11 +1873,17 @@ COMPILATION ERROR CODES
65 different names for subpatterns of the same number are
not allowed
66 (*MARK) must have an argument
- 67 this version of PCRE is not compiled with PCRE_UCP support
+ 67 this version of PCRE is not compiled with Unicode property
+ support
68 \c must be followed by an ASCII character
69 \k is not followed by a braced, angle-bracketed, or quoted name
+ 70 internal error: unknown opcode in find_fixedlength()
+ 71 \N is not supported in a class
+ 72 too many forward references
+ 73 disallowed Unicode code point (>= 0xd800 && <= 0xdfff)
+ 74 invalid UTF-16 string (specifically UTF-16)
- The numbers 32 and 10000 in errors 48 and 49 are defaults; different
+ The numbers 32 and 10000 in errors 48 and 49 are defaults; different
values may be used if the limits were changed when PCRE was built.
@@ -1471,54 +1892,54 @@ STUDYING A PATTERN
pcre_extra *pcre_study(const pcre *code, int options
const char **errptr);
- If a compiled pattern is going to be used several times, it is worth
+ If a compiled pattern is going to be used several times, it is worth
spending more time analyzing it in order to speed up the time taken for
- matching. The function pcre_study() takes a pointer to a compiled pat-
+ matching. The function pcre_study() takes a pointer to a compiled pat-
tern as its first argument. If studying the pattern produces additional
- information that will help speed up matching, pcre_study() returns a
- pointer to a pcre_extra block, in which the study_data field points to
+ information that will help speed up matching, pcre_study() returns a
+ pointer to a pcre_extra block, in which the study_data field points to
the results of the study.
The returned value from pcre_study() can be passed directly to
- pcre_exec() or pcre_dfa_exec(). However, a pcre_extra block also con-
- tains other fields that can be set by the caller before the block is
+ pcre_exec() or pcre_dfa_exec(). However, a pcre_extra block also con-
+ tains other fields that can be set by the caller before the block is
passed; these are described below in the section on matching a pattern.
- If studying the pattern does not produce any useful information,
+ If studying the pattern does not produce any useful information,
pcre_study() returns NULL. In that circumstance, if the calling program
- wants to pass any of the other fields to pcre_exec() or
+ wants to pass any of the other fields to pcre_exec() or
pcre_dfa_exec(), it must set up its own pcre_extra block.
The second argument of pcre_study() contains option bits. There is only
- one option: PCRE_STUDY_JIT_COMPILE. If this is set, and the just-in-
- time compiler is available, the pattern is further compiled into
- machine code that executes much faster than the pcre_exec() matching
+ one option: PCRE_STUDY_JIT_COMPILE. If this is set, and the just-in-
+ time compiler is available, the pattern is further compiled into
+ machine code that executes much faster than the pcre_exec() matching
function. If the just-in-time compiler is not available, this option is
ignored. All other bits in the options argument must be zero.
- JIT compilation is a heavyweight optimization. It can take some time
- for patterns to be analyzed, and for one-off matches and simple pat-
- terns the benefit of faster execution might be offset by a much slower
+ JIT compilation is a heavyweight optimization. It can take some time
+ for patterns to be analyzed, and for one-off matches and simple pat-
+ terns the benefit of faster execution might be offset by a much slower
study time. Not all patterns can be optimized by the JIT compiler. For
- those that cannot be handled, matching automatically falls back to the
- pcre_exec() interpreter. For more details, see the pcrejit documenta-
+ those that cannot be handled, matching automatically falls back to the
+ pcre_exec() interpreter. For more details, see the pcrejit documenta-
tion.
- The third argument for pcre_study() is a pointer for an error message.
- If studying succeeds (even if no data is returned), the variable it
- points to is set to NULL. Otherwise it is set to point to a textual
+ The third argument for pcre_study() is a pointer for an error message.
+ If studying succeeds (even if no data is returned), the variable it
+ points to is set to NULL. Otherwise it is set to point to a textual
error message. This is a static string that is part of the library. You
- must not try to free it. You should test the error pointer for NULL
+ must not try to free it. You should test the error pointer for NULL
after calling pcre_study(), to be sure that it has run successfully.
- When you are finished with a pattern, you can free the memory used for
+ When you are finished with a pattern, you can free the memory used for
the study data by calling pcre_free_study(). This function was added to
- the API for release 8.20. For earlier versions, the memory could be
- freed with pcre_free(), just like the pattern itself. This will still
- work in cases where PCRE_STUDY_JIT_COMPILE is not used, but it is
+ the API for release 8.20. For earlier versions, the memory could be
+ freed with pcre_free(), just like the pattern itself. This will still
+ work in cases where PCRE_STUDY_JIT_COMPILE is not used, but it is
advisable to change to the new function when convenient.
- This is a typical way in which pcre_study() is used (except that in a
+ This is a typical way in which pcre_study() is used (except that in a
real application there should be tests for errors):
int rc;
@@ -1538,15 +1959,16 @@ STUDYING A PATTERN
Studying a pattern does two things: first, a lower bound for the length
of subject string that is needed to match the pattern is computed. This
does not mean that there are any strings of that length that match, but
- it does guarantee that no shorter strings match. The value is used by
- pcre_exec() and pcre_dfa_exec() to avoid wasting time by trying to
- match strings that are shorter than the lower bound. You can find out
+ it does guarantee that no shorter strings match. The value is used by
+ pcre_exec() and pcre_dfa_exec() to avoid wasting time by trying to
+ match strings that are shorter than the lower bound. You can find out
the value in a calling program via the pcre_fullinfo() function.
Studying a pattern is also useful for non-anchored patterns that do not
- have a single fixed starting character. A bitmap of possible starting
- bytes is created. This speeds up finding a position in the subject at
- which to start matching.
+ have a single fixed starting character. A bitmap of possible starting
+ bytes is created. This speeds up finding a position in the subject at
+ which to start matching. (In 16-bit mode, the bitmap is used for 16-bit
+ values less than 256.)
These two optimizations apply to both pcre_exec() and pcre_dfa_exec().
However, they are not used by pcre_exec() if pcre_study() is called
@@ -1623,8 +2045,8 @@ INFORMATION ABOUT A PATTERN
int what, void *where);
The pcre_fullinfo() function returns information about a compiled pat-
- tern. It replaces the obsolete pcre_info() function, which is neverthe-
- less retained for backwards compability (and is documented below).
+ tern. It replaces the pcre_info() function, which was removed from the
+ library at version 8.30, after more than 10 years of obsolescence.
The first argument for pcre_fullinfo() is a pointer to the compiled
pattern. The second argument is the result of pcre_study(), or NULL if
@@ -1633,15 +2055,18 @@ INFORMATION ABOUT A PATTERN
variable to receive the data. The yield of the function is zero for
success, or one of the following negative numbers:
- PCRE_ERROR_NULL the argument code was NULL
- the argument where was NULL
- PCRE_ERROR_BADMAGIC the "magic number" was not found
- PCRE_ERROR_BADOPTION the value of what was invalid
+ PCRE_ERROR_NULL the argument code was NULL
+ the argument where was NULL
+ PCRE_ERROR_BADMAGIC the "magic number" was not found
+ PCRE_ERROR_BADENDIANNESS the pattern was compiled with different
+ endianness
+ PCRE_ERROR_BADOPTION the value of what was invalid
The "magic number" is placed at the start of each compiled pattern as
- an simple check against passing an arbitrary memory pointer. Here is a
- typical call of pcre_fullinfo(), to obtain the length of the compiled
- pattern:
+ an simple check against passing an arbitrary memory pointer. The endi-
+ anness error can occur if a compiled pattern is saved and reloaded on a
+ different host. Here is a typical call of pcre_fullinfo(), to obtain
+ the length of the compiled pattern:
int rc;
size_t length;
@@ -1651,75 +2076,79 @@ INFORMATION ABOUT A PATTERN
PCRE_INFO_SIZE, /* what is required */
&length); /* where to put the data */
- The possible values for the third argument are defined in pcre.h, and
+ The possible values for the third argument are defined in pcre.h, and
are as follows:
PCRE_INFO_BACKREFMAX
- Return the number of the highest back reference in the pattern. The
- fourth argument should point to an int variable. Zero is returned if
+ Return the number of the highest back reference in the pattern. The
+ fourth argument should point to an int variable. Zero is returned if
there are no back references.
PCRE_INFO_CAPTURECOUNT
- Return the number of capturing subpatterns in the pattern. The fourth
+ Return the number of capturing subpatterns in the pattern. The fourth
argument should point to an int variable.
PCRE_INFO_DEFAULT_TABLES
- Return a pointer to the internal default character tables within PCRE.
- The fourth argument should point to an unsigned char * variable. This
+ Return a pointer to the internal default character tables within PCRE.
+ The fourth argument should point to an unsigned char * variable. This
information call is provided for internal use by the pcre_study() func-
- tion. External callers can cause PCRE to use its internal tables by
+ tion. External callers can cause PCRE to use its internal tables by
passing a NULL table pointer.
PCRE_INFO_FIRSTBYTE
- Return information about the first byte of any matched string, for a
- non-anchored pattern. The fourth argument should point to an int vari-
- able. (This option used to be called PCRE_INFO_FIRSTCHAR; the old name
- is still recognized for backwards compatibility.)
+ Return information about the first data unit of any matched string, for
+ a non-anchored pattern. (The name of this option refers to the 8-bit
+ library, where data units are bytes.) The fourth argument should point
+ to an int variable.
+
+ If there is a fixed first value, for example, the letter "c" from a
+ pattern such as (cat|cow|coyote), its value is returned. In the 8-bit
+ library, the value is always less than 256; in the 16-bit library the
+ value can be up to 0xffff.
- If there is a fixed first byte, for example, from a pattern such as
- (cat|cow|coyote), its value is returned. Otherwise, if either
+ If there is no fixed first value, and if either
- (a) the pattern was compiled with the PCRE_MULTILINE option, and every
+ (a) the pattern was compiled with the PCRE_MULTILINE option, and every
branch starts with "^", or
(b) every branch of the pattern starts with ".*" and PCRE_DOTALL is not
set (if it were set, the pattern would be anchored),
- -1 is returned, indicating that the pattern matches only at the start
- of a subject string or after any newline within the string. Otherwise
+ -1 is returned, indicating that the pattern matches only at the start
+ of a subject string or after any newline within the string. Otherwise
-2 is returned. For anchored patterns, -2 is returned.
PCRE_INFO_FIRSTTABLE
- If the pattern was studied, and this resulted in the construction of a
- 256-bit table indicating a fixed set of bytes for the first byte in any
- matching string, a pointer to the table is returned. Otherwise NULL is
- returned. The fourth argument should point to an unsigned char * vari-
- able.
+ If the pattern was studied, and this resulted in the construction of a
+ 256-bit table indicating a fixed set of values for the first data unit
+ in any matching string, a pointer to the table is returned. Otherwise
+ NULL is returned. The fourth argument should point to an unsigned char
+ * variable.
PCRE_INFO_HASCRORLF
- Return 1 if the pattern contains any explicit matches for CR or LF
- characters, otherwise 0. The fourth argument should point to an int
- variable. An explicit match is either a literal CR or LF character, or
+ Return 1 if the pattern contains any explicit matches for CR or LF
+ characters, otherwise 0. The fourth argument should point to an int
+ variable. An explicit match is either a literal CR or LF character, or
\r or \n.
PCRE_INFO_JCHANGED
- Return 1 if the (?J) or (?-J) option setting is used in the pattern,
- otherwise 0. The fourth argument should point to an int variable. (?J)
+ Return 1 if the (?J) or (?-J) option setting is used in the pattern,
+ otherwise 0. The fourth argument should point to an int variable. (?J)
and (?-J) set and unset the local PCRE_DUPNAMES option, respectively.
PCRE_INFO_JIT
- Return 1 if the pattern was studied with the PCRE_STUDY_JIT_COMPILE
- option, and just-in-time compiling was successful. The fourth argument
- should point to an int variable. A return value of 0 means that JIT
- support is not available in this version of PCRE, or that the pattern
+ Return 1 if the pattern was studied with the PCRE_STUDY_JIT_COMPILE
+ option, and just-in-time compiling was successful. The fourth argument
+ should point to an int variable. A return value of 0 means that JIT
+ support is not available in this version of PCRE, or that the pattern
was not studied with the PCRE_STUDY_JIT_COMPILE option, or that the JIT
compiler could not handle this particular pattern. See the pcrejit doc-
umentation for details of what can and cannot be handled.
@@ -1727,28 +2156,29 @@ INFORMATION ABOUT A PATTERN
PCRE_INFO_JITSIZE
If the pattern was successfully studied with the PCRE_STUDY_JIT_COMPILE
- option, return the size of the JIT compiled code, otherwise return
+ option, return the size of the JIT compiled code, otherwise return
zero. The fourth argument should point to a size_t variable.
PCRE_INFO_LASTLITERAL
- Return the value of the rightmost literal byte that must exist in any
- matched string, other than at its start, if such a byte has been
+ Return the value of the rightmost literal data unit that must exist in
+ any matched string, other than at its start, if such a value has been
recorded. The fourth argument should point to an int variable. If there
- is no such byte, -1 is returned. For anchored patterns, a last literal
- byte is recorded only if it follows something of variable length. For
+ is no such value, -1 is returned. For anchored patterns, a last literal
+ value is recorded only if it follows something of variable length. For
example, for the pattern /^a\d+z\d+/ the returned value is "z", but for
/^a\dz\d/ the returned value is -1.
PCRE_INFO_MINLENGTH
- If the pattern was studied and a minimum length for matching subject
- strings was computed, its value is returned. Otherwise the returned
- value is -1. The value is a number of characters, not bytes (this may
- be relevant in UTF-8 mode). The fourth argument should point to an int
- variable. A non-negative value is a lower bound to the length of any
- matching string. There may not be any strings of that length that do
- actually match, but every string that does match is at least that long.
+ If the pattern was studied and a minimum length for matching subject
+ strings was computed, its value is returned. Otherwise the returned
+ value is -1. The value is a number of characters, which in UTF-8 mode
+ may be different from the number of bytes. The fourth argument should
+ point to an int variable. A non-negative value is a lower bound to the
+ length of any matching string. There may not be any strings of that
+ length that do actually match, but every string that does match is at
+ least that long.
PCRE_INFO_NAMECOUNT
PCRE_INFO_NAMEENTRYSIZE
@@ -1768,10 +2198,12 @@ INFORMATION ABOUT A PATTERN
gives the number of entries, and PCRE_INFO_NAMEENTRYSIZE gives the size
of each entry; both of these return an int value. The entry size
depends on the length of the longest name. PCRE_INFO_NAMETABLE returns
- a pointer to the first entry of the table (a pointer to char). The
- first two bytes of each entry are the number of the capturing parenthe-
- sis, most significant byte first. The rest of the entry is the corre-
- sponding name, zero terminated.
+ a pointer to the first entry of the table. This is a pointer to char in
+ the 8-bit library, where the first two bytes of each entry are the num-
+ ber of the capturing parenthesis, most significant byte first. In the
+ 16-bit library, the pointer points to 16-bit data units, the first of
+ which contains the parenthesis number. The rest of the entry is the
+ corresponding name, zero terminated.
The names are in alphabetical order. Duplicate names may appear if (?|
is used to create multiple groups with the same number, as described in
@@ -1784,8 +2216,8 @@ INFORMATION ABOUT A PATTERN
terns may have lower numbers.
As a simple example of the name/number table, consider the following
- pattern (assume PCRE_EXTENDED is set, so white space - including new-
- lines - is ignored):
+ pattern after compilation by the 8-bit library (assume PCRE_EXTENDED is
+ set, so white space - including newlines - is ignored):
(?<date> (?<year>(\d\d)?\d\d) -
(?<month>\d\d) - (?<day>\d\d) )
@@ -1838,68 +2270,47 @@ INFORMATION ABOUT A PATTERN
PCRE_INFO_SIZE
- Return the size of the compiled pattern. The fourth argument should
- point to a size_t variable. This value does not include the size of the
- pcre structure that is returned by pcre_compile(). The value that is
- passed as the argument to pcre_malloc() when pcre_compile() is getting
- memory in which to place the compiled data is the value returned by
- this option plus the size of the pcre structure. Studying a compiled
- pattern, with or without JIT, does not alter the value returned by this
- option.
+ Return the size of the compiled pattern in bytes (for both libraries).
+ The fourth argument should point to a size_t variable. This value does
+ not include the size of the pcre structure that is returned by
+ pcre_compile(). The value that is passed as the argument to pcre_mal-
+ loc() when pcre_compile() is getting memory in which to place the com-
+ piled data is the value returned by this option plus the size of the
+ pcre structure. Studying a compiled pattern, with or without JIT, does
+ not alter the value returned by this option.
PCRE_INFO_STUDYSIZE
- Return the size of the data block pointed to by the study_data field in
- a pcre_extra block. If pcre_extra is NULL, or there is no study data,
- zero is returned. The fourth argument should point to a size_t vari-
- able. The study_data field is set by pcre_study() to record informa-
- tion that will speed up matching (see the section entitled "Studying a
- pattern" above). The format of the study_data block is private, but its
- length is made available via this option so that it can be saved and
- restored (see the pcreprecompile documentation for details).
-
-
-OBSOLETE INFO FUNCTION
-
- int pcre_info(const pcre *code, int *optptr, int *firstcharptr);
-
- The pcre_info() function is now obsolete because its interface is too
- restrictive to return all the available data about a compiled pattern.
- New programs should use pcre_fullinfo() instead. The yield of
- pcre_info() is the number of capturing subpatterns, or one of the fol-
- lowing negative numbers:
-
- PCRE_ERROR_NULL the argument code was NULL
- PCRE_ERROR_BADMAGIC the "magic number" was not found
-
- If the optptr argument is not NULL, a copy of the options with which
- the pattern was compiled is placed in the integer it points to (see
- PCRE_INFO_OPTIONS above).
-
- If the pattern is not anchored and the firstcharptr argument is not
- NULL, it is used to pass back information about the first character of
- any matched string (see PCRE_INFO_FIRSTBYTE above).
+ Return the size in bytes of the data block pointed to by the study_data
+ field in a pcre_extra block. If pcre_extra is NULL, or there is no
+ study data, zero is returned. The fourth argument should point to a
+ size_t variable. The study_data field is set by pcre_study() to record
+ information that will speed up matching (see the section entitled
+ "Studying a pattern" above). The format of the study_data block is pri-
+ vate, but its length is made available via this option so that it can
+ be saved and restored (see the pcreprecompile documentation for
+ details).
REFERENCE COUNTS
int pcre_refcount(pcre *code, int adjust);
- The pcre_refcount() function is used to maintain a reference count in
+ The pcre_refcount() function is used to maintain a reference count in
the data block that contains a compiled pattern. It is provided for the
- benefit of applications that operate in an object-oriented manner,
+ benefit of applications that operate in an object-oriented manner,
where different parts of the application may be using the same compiled
pattern, but you want to free the block when they are all done.
When a pattern is compiled, the reference count field is initialized to
- zero. It is changed only by calling this function, whose action is to
- add the adjust value (which may be positive or negative) to it. The
+ zero. It is changed only by calling this function, whose action is to
+ add the adjust value (which may be positive or negative) to it. The
yield of the function is the new value. However, the value of the count
- is constrained to lie between 0 and 65535, inclusive. If the new value
+ is constrained to lie between 0 and 65535, inclusive. If the new value
is outside these limits, it is forced to the appropriate limit value.
- Except when it is zero, the reference count is not correctly preserved
- if a pattern is compiled on one host and then transferred to a host
+ Except when it is zero, the reference count is not correctly preserved
+ if a pattern is compiled on one host and then transferred to a host
whose byte-order is different. (This seems a highly unlikely scenario.)
@@ -1909,22 +2320,22 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION
const char *subject, int length, int startoffset,
int options, int *ovector, int ovecsize);
- The function pcre_exec() is called to match a subject string against a
- compiled pattern, which is passed in the code argument. If the pattern
- was studied, the result of the study should be passed in the extra
- argument. You can call pcre_exec() with the same code and extra argu-
- ments as many times as you like, in order to match different subject
+ The function pcre_exec() is called to match a subject string against a
+ compiled pattern, which is passed in the code argument. If the pattern
+ was studied, the result of the study should be passed in the extra
+ argument. You can call pcre_exec() with the same code and extra argu-
+ ments as many times as you like, in order to match different subject
strings with the same pattern.
- This function is the main matching facility of the library, and it
- operates in a Perl-like manner. For specialist use there is also an
- alternative matching function, which is described below in the section
+ This function is the main matching facility of the library, and it
+ operates in a Perl-like manner. For specialist use there is also an
+ alternative matching function, which is described below in the section
about the pcre_dfa_exec() function.
- In most applications, the pattern will have been compiled (and option-
- ally studied) in the same process that calls pcre_exec(). However, it
+ In most applications, the pattern will have been compiled (and option-
+ ally studied) in the same process that calls pcre_exec(). However, it
is possible to save compiled patterns and study data, and then use them
- later in different processes, possibly even on different hosts. For a
+ later in different processes, possibly even on different hosts. For a
discussion about this, see the pcreprecompile documentation.
Here is an example of a simple call to pcre_exec():
@@ -1943,10 +2354,10 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION
Extra data for pcre_exec()
- If the extra argument is not NULL, it must point to a pcre_extra data
- block. The pcre_study() function returns such a block (when it doesn't
- return NULL), but you can also create one for yourself, and pass addi-
- tional information in it. The pcre_extra block contains the following
+ If the extra argument is not NULL, it must point to a pcre_extra data
+ block. The pcre_study() function returns such a block (when it doesn't
+ return NULL), but you can also create one for yourself, and pass addi-
+ tional information in it. The pcre_extra block contains the following
fields (not necessarily in this order):
unsigned long int flags;
@@ -1958,6 +2369,9 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION
const unsigned char *tables;
unsigned char **mark;
+ In the 16-bit version of this structure, the mark field has type
+ "PCRE_UCHAR16 **".
+
The flags field is a bitmap that specifies which of the other fields
are set. The flag bits are:
@@ -2036,16 +2450,16 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION
tion for a discussion of saving compiled patterns for later use.
If PCRE_EXTRA_MARK is set in the flags field, the mark field must be
- set to point to a char * variable. If the pattern contains any back-
+ set to point to a suitable variable. If the pattern contains any back-
tracking control verbs such as (*MARK:NAME), and the execution ends up
with a name to pass back, a pointer to the name string (zero termi-
nated) is placed in the variable pointed to by the mark field. The
names are within the compiled pattern; if you wish to retain such a
name you must copy it before freeing the memory of a compiled pattern.
If there is no name to pass back, the variable pointed to by the mark
- field set to NULL. For details of the backtracking control verbs, see
- the section entitled "Backtracking control" in the pcrepattern documen-
- tation.
+ field is set to NULL. For details of the backtracking control verbs,
+ see the section entitled "Backtracking control" in the pcrepattern doc-
+ umentation.
Option bits for pcre_exec()
@@ -2219,199 +2633,198 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION
UTF-8 string is automatically checked when pcre_exec() is subsequently
called. The value of startoffset is also checked to ensure that it
points to the start of a UTF-8 character. There is a discussion about
- the validity of UTF-8 strings in the section on UTF-8 support in the
- main pcre page. If an invalid UTF-8 sequence of bytes is found,
- pcre_exec() returns the error PCRE_ERROR_BADUTF8 or, if PCRE_PAR-
- TIAL_HARD is set and the problem is a truncated UTF-8 character at the
- end of the subject, PCRE_ERROR_SHORTUTF8. In both cases, information
- about the precise nature of the error may also be returned (see the
- descriptions of these errors in the section entitled Error return val-
- ues from pcre_exec() below). If startoffset contains a value that does
- not point to the start of a UTF-8 character (or to the end of the sub-
- ject), PCRE_ERROR_BADUTF8_OFFSET is returned.
-
- If you already know that your subject is valid, and you want to skip
- these checks for performance reasons, you can set the
- PCRE_NO_UTF8_CHECK option when calling pcre_exec(). You might want to
- do this for the second and subsequent calls to pcre_exec() if you are
- making repeated calls to find all the matches in a single subject
- string. However, you should be sure that the value of startoffset
- points to the start of a UTF-8 character (or the end of the subject).
- When PCRE_NO_UTF8_CHECK is set, the effect of passing an invalid UTF-8
- string as a subject or an invalid value of startoffset is undefined.
- Your program may crash.
+ the validity of UTF-8 strings in the pcreunicode page. If an invalid
+ sequence of bytes is found, pcre_exec() returns the error
+ PCRE_ERROR_BADUTF8 or, if PCRE_PARTIAL_HARD is set and the problem is a
+ truncated character at the end of the subject, PCRE_ERROR_SHORTUTF8. In
+ both cases, information about the precise nature of the error may also
+ be returned (see the descriptions of these errors in the section enti-
+ tled Error return values from pcre_exec() below). If startoffset con-
+ tains a value that does not point to the start of a UTF-8 character (or
+ to the end of the subject), PCRE_ERROR_BADUTF8_OFFSET is returned.
+
+ If you already know that your subject is valid, and you want to skip
+ these checks for performance reasons, you can set the
+ PCRE_NO_UTF8_CHECK option when calling pcre_exec(). You might want to
+ do this for the second and subsequent calls to pcre_exec() if you are
+ making repeated calls to find all the matches in a single subject
+ string. However, you should be sure that the value of startoffset
+ points to the start of a character (or the end of the subject). When
+ PCRE_NO_UTF8_CHECK is set, the effect of passing an invalid string as a
+ subject or an invalid value of startoffset is undefined. Your program
+ may crash.
PCRE_PARTIAL_HARD
PCRE_PARTIAL_SOFT
- These options turn on the partial matching feature. For backwards com-
- patibility, PCRE_PARTIAL is a synonym for PCRE_PARTIAL_SOFT. A partial
- match occurs if the end of the subject string is reached successfully,
- but there are not enough subject characters to complete the match. If
+ These options turn on the partial matching feature. For backwards com-
+ patibility, PCRE_PARTIAL is a synonym for PCRE_PARTIAL_SOFT. A partial
+ match occurs if the end of the subject string is reached successfully,
+ but there are not enough subject characters to complete the match. If
this happens when PCRE_PARTIAL_SOFT (but not PCRE_PARTIAL_HARD) is set,
- matching continues by testing any remaining alternatives. Only if no
- complete match can be found is PCRE_ERROR_PARTIAL returned instead of
- PCRE_ERROR_NOMATCH. In other words, PCRE_PARTIAL_SOFT says that the
- caller is prepared to handle a partial match, but only if no complete
+ matching continues by testing any remaining alternatives. Only if no
+ complete match can be found is PCRE_ERROR_PARTIAL returned instead of
+ PCRE_ERROR_NOMATCH. In other words, PCRE_PARTIAL_SOFT says that the
+ caller is prepared to handle a partial match, but only if no complete
match can be found.
- If PCRE_PARTIAL_HARD is set, it overrides PCRE_PARTIAL_SOFT. In this
- case, if a partial match is found, pcre_exec() immediately returns
- PCRE_ERROR_PARTIAL, without considering any other alternatives. In
- other words, when PCRE_PARTIAL_HARD is set, a partial match is consid-
+ If PCRE_PARTIAL_HARD is set, it overrides PCRE_PARTIAL_SOFT. In this
+ case, if a partial match is found, pcre_exec() immediately returns
+ PCRE_ERROR_PARTIAL, without considering any other alternatives. In
+ other words, when PCRE_PARTIAL_HARD is set, a partial match is consid-
ered to be more important that an alternative complete match.
- In both cases, the portion of the string that was inspected when the
+ In both cases, the portion of the string that was inspected when the
partial match was found is set as the first matching string. There is a
- more detailed discussion of partial and multi-segment matching, with
+ more detailed discussion of partial and multi-segment matching, with
examples, in the pcrepartial documentation.
The string to be matched by pcre_exec()
- The subject string is passed to pcre_exec() as a pointer in subject, a
- length (in bytes) in length, and a starting byte offset in startoffset.
- If this is negative or greater than the length of the subject,
- pcre_exec() returns PCRE_ERROR_BADOFFSET. When the starting offset is
- zero, the search for a match starts at the beginning of the subject,
+ The subject string is passed to pcre_exec() as a pointer in subject, a
+ length in bytes in length, and a starting byte offset in startoffset.
+ If this is negative or greater than the length of the subject,
+ pcre_exec() returns PCRE_ERROR_BADOFFSET. When the starting offset is
+ zero, the search for a match starts at the beginning of the subject,
and this is by far the most common case. In UTF-8 mode, the byte offset
- must point to the start of a UTF-8 character (or the end of the sub-
- ject). Unlike the pattern string, the subject may contain binary zero
+ must point to the start of a UTF-8 character (or the end of the sub-
+ ject). Unlike the pattern string, the subject may contain binary zero
bytes.
- A non-zero starting offset is useful when searching for another match
- in the same subject by calling pcre_exec() again after a previous suc-
- cess. Setting startoffset differs from just passing over a shortened
- string and setting PCRE_NOTBOL in the case of a pattern that begins
+ A non-zero starting offset is useful when searching for another match
+ in the same subject by calling pcre_exec() again after a previous suc-
+ cess. Setting startoffset differs from just passing over a shortened
+ string and setting PCRE_NOTBOL in the case of a pattern that begins
with any kind of lookbehind. For example, consider the pattern
\Biss\B
- which finds occurrences of "iss" in the middle of words. (\B matches
- only if the current position in the subject is not a word boundary.)
- When applied to the string "Mississipi" the first call to pcre_exec()
- finds the first occurrence. If pcre_exec() is called again with just
- the remainder of the subject, namely "issipi", it does not match,
+ which finds occurrences of "iss" in the middle of words. (\B matches
+ only if the current position in the subject is not a word boundary.)
+ When applied to the string "Mississipi" the first call to pcre_exec()
+ finds the first occurrence. If pcre_exec() is called again with just
+ the remainder of the subject, namely "issipi", it does not match,
because \B is always false at the start of the subject, which is deemed
- to be a word boundary. However, if pcre_exec() is passed the entire
+ to be a word boundary. However, if pcre_exec() is passed the entire
string again, but with startoffset set to 4, it finds the second occur-
- rence of "iss" because it is able to look behind the starting point to
+ rence of "iss" because it is able to look behind the starting point to
discover that it is preceded by a letter.
- Finding all the matches in a subject is tricky when the pattern can
+ Finding all the matches in a subject is tricky when the pattern can
match an empty string. It is possible to emulate Perl's /g behaviour by
- first trying the match again at the same offset, with the
- PCRE_NOTEMPTY_ATSTART and PCRE_ANCHORED options, and then if that
- fails, advancing the starting offset and trying an ordinary match
+ first trying the match again at the same offset, with the
+ PCRE_NOTEMPTY_ATSTART and PCRE_ANCHORED options, and then if that
+ fails, advancing the starting offset and trying an ordinary match
again. There is some code that demonstrates how to do this in the pcre-
demo sample program. In the most general case, you have to check to see
- if the newline convention recognizes CRLF as a newline, and if so, and
+ if the newline convention recognizes CRLF as a newline, and if so, and
the current character is CR followed by LF, advance the starting offset
by two characters instead of one.
- If a non-zero starting offset is passed when the pattern is anchored,
+ If a non-zero starting offset is passed when the pattern is anchored,
one attempt to match at the given offset is made. This can only succeed
- if the pattern does not require the match to be at the start of the
+ if the pattern does not require the match to be at the start of the
subject.
How pcre_exec() returns captured substrings
- In general, a pattern matches a certain portion of the subject, and in
- addition, further substrings from the subject may be picked out by
- parts of the pattern. Following the usage in Jeffrey Friedl's book,
- this is called "capturing" in what follows, and the phrase "capturing
- subpattern" is used for a fragment of a pattern that picks out a sub-
- string. PCRE supports several other kinds of parenthesized subpattern
+ In general, a pattern matches a certain portion of the subject, and in
+ addition, further substrings from the subject may be picked out by
+ parts of the pattern. Following the usage in Jeffrey Friedl's book,
+ this is called "capturing" in what follows, and the phrase "capturing
+ subpattern" is used for a fragment of a pattern that picks out a sub-
+ string. PCRE supports several other kinds of parenthesized subpattern
that do not cause substrings to be captured.
Captured substrings are returned to the caller via a vector of integers
- whose address is passed in ovector. The number of elements in the vec-
- tor is passed in ovecsize, which must be a non-negative number. Note:
+ whose address is passed in ovector. The number of elements in the vec-
+ tor is passed in ovecsize, which must be a non-negative number. Note:
this argument is NOT the size of ovector in bytes.
- The first two-thirds of the vector is used to pass back captured sub-
- strings, each substring using a pair of integers. The remaining third
- of the vector is used as workspace by pcre_exec() while matching cap-
- turing subpatterns, and is not available for passing back information.
- The number passed in ovecsize should always be a multiple of three. If
+ The first two-thirds of the vector is used to pass back captured sub-
+ strings, each substring using a pair of integers. The remaining third
+ of the vector is used as workspace by pcre_exec() while matching cap-
+ turing subpatterns, and is not available for passing back information.
+ The number passed in ovecsize should always be a multiple of three. If
it is not, it is rounded down.
- When a match is successful, information about captured substrings is
- returned in pairs of integers, starting at the beginning of ovector,
- and continuing up to two-thirds of its length at the most. The first
- element of each pair is set to the byte offset of the first character
- in a substring, and the second is set to the byte offset of the first
- character after the end of a substring. Note: these values are always
+ When a match is successful, information about captured substrings is
+ returned in pairs of integers, starting at the beginning of ovector,
+ and continuing up to two-thirds of its length at the most. The first
+ element of each pair is set to the byte offset of the first character
+ in a substring, and the second is set to the byte offset of the first
+ character after the end of a substring. Note: these values are always
byte offsets, even in UTF-8 mode. They are not character counts.
- The first pair of integers, ovector[0] and ovector[1], identify the
- portion of the subject string matched by the entire pattern. The next
- pair is used for the first capturing subpattern, and so on. The value
+ The first pair of integers, ovector[0] and ovector[1], identify the
+ portion of the subject string matched by the entire pattern. The next
+ pair is used for the first capturing subpattern, and so on. The value
returned by pcre_exec() is one more than the highest numbered pair that
- has been set. For example, if two substrings have been captured, the
- returned value is 3. If there are no capturing subpatterns, the return
+ has been set. For example, if two substrings have been captured, the
+ returned value is 3. If there are no capturing subpatterns, the return
value from a successful match is 1, indicating that just the first pair
of offsets has been set.
If a capturing subpattern is matched repeatedly, it is the last portion
of the string that it matched that is returned.
- If the vector is too small to hold all the captured substring offsets,
+ If the vector is too small to hold all the captured substring offsets,
it is used as far as possible (up to two-thirds of its length), and the
- function returns a value of zero. If neither the actual string matched
- not any captured substrings are of interest, pcre_exec() may be called
- with ovector passed as NULL and ovecsize as zero. However, if the pat-
- tern contains back references and the ovector is not big enough to
- remember the related substrings, PCRE has to get additional memory for
- use during matching. Thus it is usually advisable to supply an ovector
+ function returns a value of zero. If neither the actual string matched
+ not any captured substrings are of interest, pcre_exec() may be called
+ with ovector passed as NULL and ovecsize as zero. However, if the pat-
+ tern contains back references and the ovector is not big enough to
+ remember the related substrings, PCRE has to get additional memory for
+ use during matching. Thus it is usually advisable to supply an ovector
of reasonable size.
- There are some cases where zero is returned (indicating vector over-
- flow) when in fact the vector is exactly the right size for the final
+ There are some cases where zero is returned (indicating vector over-
+ flow) when in fact the vector is exactly the right size for the final
match. For example, consider the pattern
(a)(?:(b)c|bd)
- If a vector of 6 elements (allowing for only 1 captured substring) is
+ If a vector of 6 elements (allowing for only 1 captured substring) is
given with subject string "abd", pcre_exec() will try to set the second
captured string, thereby recording a vector overflow, before failing to
- match "c" and backing up to try the second alternative. The zero
- return, however, does correctly indicate that the maximum number of
+ match "c" and backing up to try the second alternative. The zero
+ return, however, does correctly indicate that the maximum number of
slots (namely 2) have been filled. In similar cases where there is tem-
- porary overflow, but the final number of used slots is actually less
+ porary overflow, but the final number of used slots is actually less
than the maximum, a non-zero value is returned.
The pcre_fullinfo() function can be used to find out how many capturing
- subpatterns there are in a compiled pattern. The smallest size for
- ovector that will allow for n captured substrings, in addition to the
+ subpatterns there are in a compiled pattern. The smallest size for
+ ovector that will allow for n captured substrings, in addition to the
offsets of the substring matched by the whole pattern, is (n+1)*3.
- It is possible for capturing subpattern number n+1 to match some part
+ It is possible for capturing subpattern number n+1 to match some part
of the subject when subpattern n has not been used at all. For example,
- if the string "abc" is matched against the pattern (a|(z))(bc) the
+ if the string "abc" is matched against the pattern (a|(z))(bc) the
return from the function is 4, and subpatterns 1 and 3 are matched, but
- 2 is not. When this happens, both values in the offset pairs corre-
+ 2 is not. When this happens, both values in the offset pairs corre-
sponding to unused subpatterns are set to -1.
- Offset values that correspond to unused subpatterns at the end of the
- expression are also set to -1. For example, if the string "abc" is
- matched against the pattern (abc)(x(yz)?)? subpatterns 2 and 3 are not
- matched. The return from the function is 2, because the highest used
- capturing subpattern number is 1, and the offsets for for the second
- and third capturing subpatterns (assuming the vector is large enough,
+ Offset values that correspond to unused subpatterns at the end of the
+ expression are also set to -1. For example, if the string "abc" is
+ matched against the pattern (abc)(x(yz)?)? subpatterns 2 and 3 are not
+ matched. The return from the function is 2, because the highest used
+ capturing subpattern number is 1, and the offsets for for the second
+ and third capturing subpatterns (assuming the vector is large enough,
of course) are set to -1.
- Note: Elements in the first two-thirds of ovector that do not corre-
- spond to capturing parentheses in the pattern are never changed. That
- is, if a pattern contains n capturing parentheses, no more than ovec-
- tor[0] to ovector[2n+1] are set by pcre_exec(). The other elements (in
+ Note: Elements in the first two-thirds of ovector that do not corre-
+ spond to capturing parentheses in the pattern are never changed. That
+ is, if a pattern contains n capturing parentheses, no more than ovec-
+ tor[0] to ovector[2n+1] are set by pcre_exec(). The other elements (in
the first two-thirds) retain whatever values they previously had.
- Some convenience functions are provided for extracting the captured
+ Some convenience functions are provided for extracting the captured
substrings as separate strings. These are described below.
Error return values from pcre_exec()
- If pcre_exec() fails, it returns a negative number. The following are
+ If pcre_exec() fails, it returns a negative number. The following are
defined in the header file:
PCRE_ERROR_NOMATCH (-1)
@@ -2420,7 +2833,7 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION
PCRE_ERROR_NULL (-2)
- Either code or subject was passed as NULL, or ovector was NULL and
+ Either code or subject was passed as NULL, or ovector was NULL and
ovecsize was not zero.
PCRE_ERROR_BADOPTION (-3)
@@ -2429,82 +2842,82 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION
PCRE_ERROR_BADMAGIC (-4)
- PCRE stores a 4-byte "magic number" at the start of the compiled code,
+ PCRE stores a 4-byte "magic number" at the start of the compiled code,
to catch the case when it is passed a junk pointer and to detect when a
pattern that was compiled in an environment of one endianness is run in
- an environment with the other endianness. This is the error that PCRE
+ an environment with the other endianness. This is the error that PCRE
gives when the magic number is not present.
PCRE_ERROR_UNKNOWN_OPCODE (-5)
While running the pattern match, an unknown item was encountered in the
- compiled pattern. This error could be caused by a bug in PCRE or by
+ compiled pattern. This error could be caused by a bug in PCRE or by
overwriting of the compiled pattern.
PCRE_ERROR_NOMEMORY (-6)
- If a pattern contains back references, but the ovector that is passed
+ If a pattern contains back references, but the ovector that is passed
to pcre_exec() is not big enough to remember the referenced substrings,
- PCRE gets a block of memory at the start of matching to use for this
- purpose. If the call via pcre_malloc() fails, this error is given. The
+ PCRE gets a block of memory at the start of matching to use for this
+ purpose. If the call via pcre_malloc() fails, this error is given. The
memory is automatically freed at the end of matching.
- This error is also given if pcre_stack_malloc() fails in pcre_exec().
- This can happen only when PCRE has been compiled with --disable-stack-
+ This error is also given if pcre_stack_malloc() fails in pcre_exec().
+ This can happen only when PCRE has been compiled with --disable-stack-
for-recursion.
PCRE_ERROR_NOSUBSTRING (-7)
- This error is used by the pcre_copy_substring(), pcre_get_substring(),
+ This error is used by the pcre_copy_substring(), pcre_get_substring(),
and pcre_get_substring_list() functions (see below). It is never
returned by pcre_exec().
PCRE_ERROR_MATCHLIMIT (-8)
- The backtracking limit, as specified by the match_limit field in a
- pcre_extra structure (or defaulted) was reached. See the description
+ The backtracking limit, as specified by the match_limit field in a
+ pcre_extra structure (or defaulted) was reached. See the description
above.
PCRE_ERROR_CALLOUT (-9)
This error is never generated by pcre_exec() itself. It is provided for
- use by callout functions that want to yield a distinctive error code.
+ use by callout functions that want to yield a distinctive error code.
See the pcrecallout documentation for details.
PCRE_ERROR_BADUTF8 (-10)
- A string that contains an invalid UTF-8 byte sequence was passed as a
- subject, and the PCRE_NO_UTF8_CHECK option was not set. If the size of
- the output vector (ovecsize) is at least 2, the byte offset to the
- start of the the invalid UTF-8 character is placed in the first ele-
- ment, and a reason code is placed in the second element. The reason
+ A string that contains an invalid UTF-8 byte sequence was passed as a
+ subject, and the PCRE_NO_UTF8_CHECK option was not set. If the size of
+ the output vector (ovecsize) is at least 2, the byte offset to the
+ start of the the invalid UTF-8 character is placed in the first ele-
+ ment, and a reason code is placed in the second element. The reason
codes are listed in the following section. For backward compatibility,
- if PCRE_PARTIAL_HARD is set and the problem is a truncated UTF-8 char-
- acter at the end of the subject (reason codes 1 to 5),
+ if PCRE_PARTIAL_HARD is set and the problem is a truncated UTF-8 char-
+ acter at the end of the subject (reason codes 1 to 5),
PCRE_ERROR_SHORTUTF8 is returned instead of PCRE_ERROR_BADUTF8.
PCRE_ERROR_BADUTF8_OFFSET (-11)
- The UTF-8 byte sequence that was passed as a subject was checked and
- found to be valid (the PCRE_NO_UTF8_CHECK option was not set), but the
- value of startoffset did not point to the beginning of a UTF-8 charac-
+ The UTF-8 byte sequence that was passed as a subject was checked and
+ found to be valid (the PCRE_NO_UTF8_CHECK option was not set), but the
+ value of startoffset did not point to the beginning of a UTF-8 charac-
ter or the end of the subject.
PCRE_ERROR_PARTIAL (-12)
- The subject string did not match, but it did match partially. See the
+ The subject string did not match, but it did match partially. See the
pcrepartial documentation for details of partial matching.
PCRE_ERROR_BADPARTIAL (-13)
- This code is no longer in use. It was formerly returned when the
- PCRE_PARTIAL option was used with a compiled pattern containing items
- that were not supported for partial matching. From release 8.00
+ This code is no longer in use. It was formerly returned when the
+ PCRE_PARTIAL option was used with a compiled pattern containing items
+ that were not supported for partial matching. From release 8.00
onwards, there are no restrictions on partial matching.
PCRE_ERROR_INTERNAL (-14)
- An unexpected internal error has occurred. This error could be caused
+ An unexpected internal error has occurred. This error could be caused
by a bug in PCRE or by overwriting of the compiled pattern.
PCRE_ERROR_BADCOUNT (-15)
@@ -2514,7 +2927,7 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION
PCRE_ERROR_RECURSIONLIMIT (-21)
The internal recursion limit, as specified by the match_limit_recursion
- field in a pcre_extra structure (or defaulted) was reached. See the
+ field in a pcre_extra structure (or defaulted) was reached. See the
description above.
PCRE_ERROR_BADNEWLINE (-23)
@@ -2528,35 +2941,50 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION
PCRE_ERROR_SHORTUTF8 (-25)
- This error is returned instead of PCRE_ERROR_BADUTF8 when the subject
- string ends with a truncated UTF-8 character and the PCRE_PARTIAL_HARD
- option is set. Information about the failure is returned as for
- PCRE_ERROR_BADUTF8. It is in fact sufficient to detect this case, but
- this special error code for PCRE_PARTIAL_HARD precedes the implementa-
- tion of returned information; it is retained for backwards compatibil-
+ This error is returned instead of PCRE_ERROR_BADUTF8 when the subject
+ string ends with a truncated UTF-8 character and the PCRE_PARTIAL_HARD
+ option is set. Information about the failure is returned as for
+ PCRE_ERROR_BADUTF8. It is in fact sufficient to detect this case, but
+ this special error code for PCRE_PARTIAL_HARD precedes the implementa-
+ tion of returned information; it is retained for backwards compatibil-
ity.
PCRE_ERROR_RECURSELOOP (-26)
This error is returned when pcre_exec() detects a recursion loop within
- the pattern. Specifically, it means that either the whole pattern or a
- subpattern has been called recursively for the second time at the same
+ the pattern. Specifically, it means that either the whole pattern or a
+ subpattern has been called recursively for the second time at the same
position in the subject string. Some simple patterns that might do this
- are detected and faulted at compile time, but more complicated cases,
+ are detected and faulted at compile time, but more complicated cases,
in particular mutual recursions between two different subpatterns, can-
not be detected until run time.
PCRE_ERROR_JIT_STACKLIMIT (-27)
- This error is returned when a pattern that was successfully studied
- using the PCRE_STUDY_JIT_COMPILE option is being matched, but the mem-
- ory available for the just-in-time processing stack is not large
+ This error is returned when a pattern that was successfully studied
+ using the PCRE_STUDY_JIT_COMPILE option is being matched, but the mem-
+ ory available for the just-in-time processing stack is not large
enough. See the pcrejit documentation for more details.
+ PCRE_ERROR_BADMODE (-28)
+
+ This error is given if a pattern that was compiled by the 8-bit library
+ is passed to a 16-bit library function, or vice versa.
+
+ PCRE_ERROR_BADENDIANNESS (-29)
+
+ This error is given if a pattern that was compiled and saved is
+ reloaded on a host with different endianness. The utility function
+ pcre_pattern_to_host_byte_order() can be used to convert such a pattern
+ so that it runs on the new host.
+
Error numbers -16 to -20 and -22 are not used by pcre_exec().
Reason codes for invalid UTF-8 strings
+ This section applies only to the 8-bit library. The corresponding
+ information for the 16-bit library is given in the pcre16 page.
+
When pcre_exec() returns either PCRE_ERROR_BADUTF8 or PCRE_ERROR_SHORT-
UTF8, and the size of the output vector (ovecsize) is at least 2, the
offset of the start of the invalid UTF-8 character is placed in the
@@ -2991,8 +3419,9 @@ MATCHING A PATTERN: THE ALTERNATIVE FUNCTION
SEE ALSO
- pcrebuild(3), pcrecallout(3), pcrecpp(3)(3), pcrematching(3), pcrepar-
- tial(3), pcreposix(3), pcreprecompile(3), pcresample(3), pcrestack(3).
+ pcre16(3), pcrebuild(3), pcrecallout(3), pcrecpp(3)(3), pcrematch-
+ ing(3), pcrepartial(3), pcreposix(3), pcreprecompile(3), pcresample(3),
+ pcrestack(3).
AUTHOR
@@ -3004,11 +3433,11 @@ AUTHOR
REVISION
- Last updated: 02 December 2011
- Copyright (c) 1997-2011 University of Cambridge.
+ Last updated: 07 January 2012
+ Copyright (c) 1997-2012 University of Cambridge.
------------------------------------------------------------------------------
-
-
+
+
PCRECALLOUT(3) PCRECALLOUT(3)
@@ -3020,24 +3449,27 @@ PCRE CALLOUTS
int (*pcre_callout)(pcre_callout_block *);
+ int (*pcre16_callout)(pcre16_callout_block *);
+
PCRE provides a feature called "callout", which is a means of temporar-
ily passing control to the caller of PCRE in the middle of pattern
matching. The caller of PCRE provides an external function by putting
- its entry point in the global variable pcre_callout. By default, this
- variable contains NULL, which disables all calling out.
+ its entry point in the global variable pcre_callout (pcre16_callout for
+ the 16-bit library). By default, this variable contains NULL, which
+ disables all calling out.
- Within a regular expression, (?C) indicates the points at which the
- external function is to be called. Different callout points can be
- identified by putting a number less than 256 after the letter C. The
- default value is zero. For example, this pattern has two callout
+ Within a regular expression, (?C) indicates the points at which the
+ external function is to be called. Different callout points can be
+ identified by putting a number less than 256 after the letter C. The
+ default value is zero. For example, this pattern has two callout
points:
(?C1)abc(?C2)def
- If the PCRE_AUTO_CALLOUT option bit is set when pcre_compile() or
- pcre_compile2() is called, PCRE automatically inserts callouts, all
- with number 255, before each item in the pattern. For example, if
- PCRE_AUTO_CALLOUT is used with the pattern
+ If the PCRE_AUTO_CALLOUT option bit is set when a pattern is compiled,
+ PCRE automatically inserts callouts, all with number 255, before each
+ item in the pattern. For example, if PCRE_AUTO_CALLOUT is used with the
+ pattern
A(\d{2}|--)
@@ -3045,64 +3477,65 @@ PCRE CALLOUTS
(?C255)A(?C255)((?C255)\d{2}(?C255)|(?C255)-(?C255)-(?C255))(?C255)
- Notice that there is a callout before and after each parenthesis and
- alternation bar. Automatic callouts can be used for tracking the
- progress of pattern matching. The pcretest command has an option that
- sets automatic callouts; when it is used, the output indicates how the
- pattern is matched. This is useful information when you are trying to
+ Notice that there is a callout before and after each parenthesis and
+ alternation bar. Automatic callouts can be used for tracking the
+ progress of pattern matching. The pcretest command has an option that
+ sets automatic callouts; when it is used, the output indicates how the
+ pattern is matched. This is useful information when you are trying to
optimize the performance of a particular pattern.
- The use of callouts in a pattern makes it ineligible for optimization
+ The use of callouts in a pattern makes it ineligible for optimization
by the just-in-time compiler. Studying such a pattern with the
PCRE_STUDY_JIT_COMPILE option always fails.
MISSING CALLOUTS
- You should be aware that, because of optimizations in the way PCRE
- matches patterns by default, callouts sometimes do not happen. For
+ You should be aware that, because of optimizations in the way PCRE
+ matches patterns by default, callouts sometimes do not happen. For
example, if the pattern is
ab(?C4)cd
PCRE knows that any matching string must contain the letter "d". If the
- subject string is "abyz", the lack of "d" means that matching doesn't
- ever start, and the callout is never reached. However, with "abyd",
+ subject string is "abyz", the lack of "d" means that matching doesn't
+ ever start, and the callout is never reached. However, with "abyd",
though the result is still no match, the callout is obeyed.
- If the pattern is studied, PCRE knows the minimum length of a matching
- string, and will immediately give a "no match" return without actually
- running a match if the subject is not long enough, or, for unanchored
+ If the pattern is studied, PCRE knows the minimum length of a matching
+ string, and will immediately give a "no match" return without actually
+ running a match if the subject is not long enough, or, for unanchored
patterns, if it has been scanned far enough.
- You can disable these optimizations by passing the PCRE_NO_START_OPTI-
- MIZE option to pcre_compile(), pcre_exec(), or pcre_dfa_exec(), or by
- starting the pattern with (*NO_START_OPT). This slows down the matching
- process, but does ensure that callouts such as the example above are
- obeyed.
+ You can disable these optimizations by passing the PCRE_NO_START_OPTI-
+ MIZE option to the matching function, or by starting the pattern with
+ (*NO_START_OPT). This slows down the matching process, but does ensure
+ that callouts such as the example above are obeyed.
THE CALLOUT INTERFACE
During matching, when PCRE reaches a callout point, the external func-
- tion defined by pcre_callout is called (if it is set). This applies to
- both the pcre_exec() and the pcre_dfa_exec() matching functions. The
- only argument to the callout function is a pointer to a pcre_callout
- block. This structure contains the following fields:
-
- int version;
- int callout_number;
- int *offset_vector;
- const char *subject;
- int subject_length;
- int start_match;
- int current_position;
- int capture_top;
- int capture_last;
- void *callout_data;
- int pattern_position;
- int next_item_length;
- const unsigned char *mark;
+ tion defined by pcre_callout or pcre16_callout is called (if it is
+ set). This applies to both normal and DFA matching. The only argument
+ to the callout function is a pointer to a pcre_callout or pcre16_call-
+ out block. These structures contains the following fields:
+
+ int version;
+ int callout_number;
+ int *offset_vector;
+ const char *subject; (8-bit version)
+ PCRE_SPTR16 subject; (16-bit version)
+ int subject_length;
+ int start_match;
+ int current_position;
+ int capture_top;
+ int capture_last;
+ void *callout_data;
+ int pattern_position;
+ int next_item_length;
+ const unsigned char *mark; (8-bit version)
+ const PCRE_UCHAR16 *mark; (16-bit version)
The version field is an integer containing the version number of the
block format. The initial version was 0; the current version is 2. The
@@ -3114,14 +3547,14 @@ THE CALLOUT INTERFACE
outs, and 255 for automatically generated callouts).
The offset_vector field is a pointer to the vector of offsets that was
- passed by the caller to pcre_exec() or pcre_dfa_exec(). When
- pcre_exec() is used, the contents can be inspected in order to extract
- substrings that have been matched so far, in the same way as for
- extracting substrings after a match has completed. For pcre_dfa_exec()
- this field is not useful.
+ passed by the caller to the matching function. When pcre_exec() or
+ pcre16_exec() is used, the contents can be inspected, in order to
+ extract substrings that have been matched so far, in the same way as
+ for extracting substrings after a match has completed. For the DFA
+ matching functions, this field is not useful.
The subject and subject_length fields contain copies of the values that
- were passed to pcre_exec().
+ were passed to the matching function.
The start_match field normally contains the offset within the subject
at which the current match attempt started. However, if the escape
@@ -3133,45 +3566,45 @@ THE CALLOUT INTERFACE
The current_position field contains the offset within the subject of
the current match pointer.
- When the pcre_exec() function is used, the capture_top field contains
- one more than the number of the highest numbered captured substring so
- far. If no substrings have been captured, the value of capture_top is
- one. This is always the case when pcre_dfa_exec() is used, because it
- does not support captured substrings.
+ When the pcre_exec() or pcre16_exec() is used, the capture_top field
+ contains one more than the number of the highest numbered captured sub-
+ string so far. If no substrings have been captured, the value of cap-
+ ture_top is one. This is always the case when the DFA functions are
+ used, because they do not support captured substrings.
The capture_last field contains the number of the most recently cap-
tured substring. If no substrings have been captured, its value is -1.
- This is always the case when pcre_dfa_exec() is used.
+ This is always the case for the DFA matching functions.
- The callout_data field contains a value that is passed to pcre_exec()
- or pcre_dfa_exec() specifically so that it can be passed back in call-
- outs. It is passed in the pcre_callout field of the pcre_extra data
+ The callout_data field contains a value that is passed to a matching
+ function specifically so that it can be passed back in callouts. It is
+ passed in the callout_data field of a pcre_extra or pcre16_extra data
structure. If no such data was passed, the value of callout_data in a
- pcre_callout block is NULL. There is a description of the pcre_extra
- structure in the pcreapi documentation.
+ callout block is NULL. There is a description of the pcre_extra struc-
+ ture in the pcreapi documentation.
- The pattern_position field is present from version 1 of the pcre_call-
- out structure. It contains the offset to the next item to be matched in
- the pattern string.
+ The pattern_position field is present from version 1 of the callout
+ structure. It contains the offset to the next item to be matched in the
+ pattern string.
- The next_item_length field is present from version 1 of the pcre_call-
- out structure. It contains the length of the next item to be matched in
- the pattern string. When the callout immediately precedes an alterna-
- tion bar, a closing parenthesis, or the end of the pattern, the length
- is zero. When the callout precedes an opening parenthesis, the length
- is that of the entire subpattern.
+ The next_item_length field is present from version 1 of the callout
+ structure. It contains the length of the next item to be matched in the
+ pattern string. When the callout immediately precedes an alternation
+ bar, a closing parenthesis, or the end of the pattern, the length is
+ zero. When the callout precedes an opening parenthesis, the length is
+ that of the entire subpattern.
The pattern_position and next_item_length fields are intended to help
in distinguishing between different automatic callouts, which all have
the same callout number. However, they are set for all callouts.
- The mark field is present from version 2 of the pcre_callout structure.
- In callouts from pcre_exec() it contains a pointer to the zero-termi-
- nated name of the most recently passed (*MARK), (*PRUNE), or (*THEN)
- item in the match, or NULL if no such items have been passed. Instances
- of (*PRUNE) or (*THEN) without a name do not obliterate a previous
- (*MARK). In callouts from pcre_dfa_exec() this field always contains
- NULL.
+ The mark field is present from version 2 of the callout structure. In
+ callouts from pcre_exec() or pcre16_exec() it contains a pointer to the
+ zero-terminated name of the most recently passed (*MARK), (*PRUNE), or
+ (*THEN) item in the match, or NULL if no such items have been passed.
+ Instances of (*PRUNE) or (*THEN) without a name do not obliterate a
+ previous (*MARK). In callouts from the DFA matching functions this
+ field always contains NULL.
RETURN VALUES
@@ -3180,8 +3613,8 @@ RETURN VALUES
is zero, matching proceeds as normal. If the value is greater than
zero, matching fails at the current point, but the testing of other
matching possibilities goes ahead, just as if a lookahead assertion had
- failed. If the value is less than zero, the match is abandoned, and
- pcre_exec() or pcre_dfa_exec() returns the negative value.
+ failed. If the value is less than zero, the match is abandoned, the
+ matching function returns the negative value.
Negative values should normally be chosen from the set of
PCRE_ERROR_xxx values. In particular, PCRE_ERROR_NOMATCH forces a stan-
@@ -3199,11 +3632,11 @@ AUTHOR
REVISION
- Last updated: 30 November 2011
- Copyright (c) 1997-2011 University of Cambridge.
+ Last updated: 08 Janurary 2012
+ Copyright (c) 1997-2012 University of Cambridge.
------------------------------------------------------------------------------
-
-
+
+
PCRECOMPAT(3) PCRECOMPAT(3)
@@ -3217,8 +3650,8 @@ DIFFERENCES BETWEEN PCRE AND PERL
handle regular expressions. The differences described here are with
respect to Perl versions 5.10 and above.
- 1. PCRE has only a subset of Perl's UTF-8 and Unicode support. Details
- of what it does have are given in the pcreunicode page.
+ 1. PCRE has only a subset of Perl's Unicode support. Details of what it
+ does have are given in the pcreunicode page.
2. PCRE allows repeat quantifiers only on parenthesized assertions, but
they do not mean what you might think. For example, (?!a){3} does not
@@ -3356,10 +3789,11 @@ DIFFERENCES BETWEEN PCRE AND PERL
even on different hosts that have the other endianness. However, this
does not apply to optimized data created by the just-in-time compiler.
- (k) The alternative matching function (pcre_dfa_exec()) matches in a
- different way and is not Perl-compatible.
+ (k) The alternative matching functions (pcre_dfa_exec() and
+ pcre16_dfa_exec()) match in a different way and are not Perl-compati-
+ ble.
- (l) PCRE recognizes some special sequences such as (*CR) at the start
+ (l) PCRE recognizes some special sequences such as (*CR) at the start
of a pattern that set overall options that cannot be changed within the
pattern.
@@ -3373,11 +3807,11 @@ AUTHOR
REVISION
- Last updated: 14 November 2011
- Copyright (c) 1997-2011 University of Cambridge.
+ Last updated: 08 Januray 2012
+ Copyright (c) 1997-2012 University of Cambridge.
------------------------------------------------------------------------------
-
-
+
+
PCREPATTERN(3) PCREPATTERN(3)
@@ -3403,42 +3837,45 @@ PCRE REGULAR EXPRESSION DETAILS
intended as reference material.
The original operation of PCRE was on strings of one-byte characters.
- However, there is now also support for UTF-8 character strings. To use
- this, PCRE must be built to include UTF-8 support, and you must call
- pcre_compile() or pcre_compile2() with the PCRE_UTF8 option. There is
- also a special sequence that can be given at the start of a pattern:
+ However, there is now also support for UTF-8 strings in the original
+ library, and a second library that supports 16-bit and UTF-16 character
+ strings. To use these features, PCRE must be built to include appropri-
+ ate support. When using UTF strings you must either call the compiling
+ function with the PCRE_UTF8 or PCRE_UTF16 option, or the pattern must
+ start with one of these special sequences:
(*UTF8)
+ (*UTF16)
- Starting a pattern with this sequence is equivalent to setting the
- PCRE_UTF8 option. This feature is not Perl-compatible. How setting
- UTF-8 mode affects pattern matching is mentioned in several places
- below. There is also a summary of UTF-8 features in the pcreunicode
- page.
+ Starting a pattern with such a sequence is equivalent to setting the
+ relevant option. This feature is not Perl-compatible. How setting a UTF
+ mode affects pattern matching is mentioned in several places below.
+ There is also a summary of features in the pcreunicode page.
- Another special sequence that may appear at the start of a pattern or
- in combination with (*UTF8) is:
+ Another special sequence that may appear at the start of a pattern or
+ in combination with (*UTF8) or (*UTF16) is:
(*UCP)
- This has the same effect as setting the PCRE_UCP option: it causes
- sequences such as \d and \w to use Unicode properties to determine
+ This has the same effect as setting the PCRE_UCP option: it causes
+ sequences such as \d and \w to use Unicode properties to determine
character types, instead of recognizing only characters with codes less
than 128 via a lookup table.
- If a pattern starts with (*NO_START_OPT), it has the same effect as
+ If a pattern starts with (*NO_START_OPT), it has the same effect as
setting the PCRE_NO_START_OPTIMIZE option either at compile or matching
time. There are also some more of these special sequences that are con-
cerned with the handling of newlines; they are described below.
- The remainder of this document discusses the patterns that are sup-
- ported by PCRE when its main matching function, pcre_exec(), is used.
- From release 6.0, PCRE offers a second matching function,
- pcre_dfa_exec(), which matches using a different algorithm that is not
- Perl-compatible. Some of the features discussed below are not available
- when pcre_dfa_exec() is used. The advantages and disadvantages of the
- alternative function, and how it differs from the normal function, are
- discussed in the pcrematching page.
+ The remainder of this document discusses the patterns that are sup-
+ ported by PCRE when one its main matching functions, pcre_exec()
+ (8-bit) or pcre16_exec() (16-bit), is used. PCRE also has alternative
+ matching functions, pcre_dfa_exec() and pcre16_dfa_exec(), which match
+ using a different algorithm that is not Perl-compatible. Some of the
+ features discussed below are not available when DFA matching is used.
+ The advantages and disadvantages of the alternative functions, and how
+ they differ from the normal functions, are discussed in the pcrematch-
+ ing page.
NEWLINE CONVENTIONS
@@ -3459,9 +3896,9 @@ NEWLINE CONVENTIONS
(*ANYCRLF) any of the three above
(*ANY) all Unicode newline sequences
- These override the default and the options given to pcre_compile() or
- pcre_compile2(). For example, on a Unix system where LF is the default
- newline sequence, the pattern
+ These override the default and the options given to the compiling func-
+ tion. For example, on a Unix system where LF is the default newline
+ sequence, the pattern
(*CR)a.b
@@ -3491,13 +3928,13 @@ CHARACTERS AND METACHARACTERS
matches a portion of a subject string that is identical to itself. When
caseless matching is specified (the PCRE_CASELESS option), letters are
- matched independently of case. In UTF-8 mode, PCRE always understands
+ matched independently of case. In a UTF mode, PCRE always understands
the concept of case for characters whose values are less than 128, so
caseless matching is always possible. For characters with higher val-
ues, the concept of case is supported if PCRE is compiled with Unicode
property support, but not otherwise. If you want to use caseless
matching for characters 128 and above, you must ensure that PCRE is
- compiled with Unicode property support as well as with UTF-8 support.
+ compiled with Unicode property support as well as with UTF support.
The power of regular expressions comes from the ability to include
alternatives and repetitions in the pattern. These are encoded in the
@@ -3552,7 +3989,7 @@ BACKSLASH
that it stands for itself. In particular, if you want to match a back-
slash, you write \\.
- In UTF-8 mode, only ASCII numbers and letters have any special meaning
+ In a UTF mode, only ASCII numbers and letters have any special meaning
after a backslash. All other characters (in particular, those whose
codepoints are greater than 127) are treated as literals.
@@ -3608,56 +4045,61 @@ BACKSLASH
inverted. Thus \cz becomes hex 1A (z is 7A), but \c{ becomes hex 3B ({
is 7B), while \c; becomes hex 7B (; is 3B). If the byte following \c
has a value greater than 127, a compile-time error occurs. This locks
- out non-ASCII characters in both byte mode and UTF-8 mode. (When PCRE
- is compiled in EBCDIC mode, all byte values are valid. A lower case
- letter is converted to upper case, and then the 0xc0 bits are flipped.)
+ out non-ASCII characters in all modes. (When PCRE is compiled in EBCDIC
+ mode, all byte values are valid. A lower case letter is converted to
+ upper case, and then the 0xc0 bits are flipped.)
By default, after \x, from zero to two hexadecimal digits are read
(letters can be in upper or lower case). Any number of hexadecimal dig-
- its may appear between \x{ and }, but the value of the character code
- must be less than 256 in non-UTF-8 mode, and less than 2**31 in UTF-8
- mode. That is, the maximum value in hexadecimal is 7FFFFFFF. Note that
- this is bigger than the largest Unicode code point, which is 10FFFF.
+ its may appear between \x{ and }, but the character code is constrained
+ as follows:
+
+ 8-bit non-UTF mode less than 0x100
+ 8-bit UTF-8 mode less than 0x10ffff and a valid codepoint
+ 16-bit non-UTF mode less than 0x10000
+ 16-bit UTF-16 mode less than 0x10ffff and a valid codepoint
+
+ Invalid Unicode codepoints are the range 0xd800 to 0xdfff (the so-
+ called "surrogate" codepoints).
- If characters other than hexadecimal digits appear between \x{ and },
+ If characters other than hexadecimal digits appear between \x{ and },
or if there is no terminating }, this form of escape is not recognized.
- Instead, the initial \x will be interpreted as a basic hexadecimal
- escape, with no following digits, giving a character whose value is
+ Instead, the initial \x will be interpreted as a basic hexadecimal
+ escape, with no following digits, giving a character whose value is
zero.
- If the PCRE_JAVASCRIPT_COMPAT option is set, the interpretation of \x
- is as just described only when it is followed by two hexadecimal dig-
- its. Otherwise, it matches a literal "x" character. In JavaScript
+ If the PCRE_JAVASCRIPT_COMPAT option is set, the interpretation of \x
+ is as just described only when it is followed by two hexadecimal dig-
+ its. Otherwise, it matches a literal "x" character. In JavaScript
mode, support for code points greater than 256 is provided by \u, which
- must be followed by four hexadecimal digits; otherwise it matches a
+ must be followed by four hexadecimal digits; otherwise it matches a
literal "u" character.
Characters whose value is less than 256 can be defined by either of the
- two syntaxes for \x (or by \u in JavaScript mode). There is no differ-
+ two syntaxes for \x (or by \u in JavaScript mode). There is no differ-
ence in the way they are handled. For example, \xdc is exactly the same
as \x{dc} (or \u00dc in JavaScript mode).
- After \0 up to two further octal digits are read. If there are fewer
- than two digits, just those that are present are used. Thus the
+ After \0 up to two further octal digits are read. If there are fewer
+ than two digits, just those that are present are used. Thus the
sequence \0\x\07 specifies two binary zeros followed by a BEL character
- (code value 7). Make sure you supply two digits after the initial zero
+ (code value 7). Make sure you supply two digits after the initial zero
if the pattern character that follows is itself an octal digit.
The handling of a backslash followed by a digit other than 0 is compli-
cated. Outside a character class, PCRE reads it and any following dig-
- its as a decimal number. If the number is less than 10, or if there
+ its as a decimal number. If the number is less than 10, or if there
have been at least that many previous capturing left parentheses in the
- expression, the entire sequence is taken as a back reference. A
- description of how this works is given later, following the discussion
+ expression, the entire sequence is taken as a back reference. A
+ description of how this works is given later, following the discussion
of parenthesized subpatterns.
- Inside a character class, or if the decimal number is greater than 9
- and there have not been that many capturing subpatterns, PCRE re-reads
+ Inside a character class, or if the decimal number is greater than 9
+ and there have not been that many capturing subpatterns, PCRE re-reads
up to three octal digits following the backslash, and uses them to gen-
- erate a data character. Any subsequent digits stand for themselves. In
- non-UTF-8 mode, the value of a character specified in octal must be
- less than \400. In UTF-8 mode, values up to \777 are permitted. For
- example:
+ erate a data character. Any subsequent digits stand for themselves. The
+ value of the character is constrained in the same way as characters
+ specified in hexadecimal. For example:
\040 is another way of writing a space
\40 is the same, provided there are fewer than 40
@@ -3670,7 +4112,7 @@ BACKSLASH
\113 might be a back reference, otherwise the
character with octal code 113
\377 might be a back reference, otherwise
- the byte consisting entirely of 1 bits
+ the value 255 (decimal)
\81 is either a back reference, or a binary zero
followed by the two characters "8" and "1"
@@ -3755,9 +4197,9 @@ BACKSLASH
are used for accented letters, and these are then matched by \w. The
use of locales with Unicode is discouraged.
- By default, in UTF-8 mode, characters with values greater than 128
+ By default, in a UTF mode, characters with values greater than 128
never match \d, \s, or \w, and always match \D, \S, and \W. These
- sequences retain their original meanings from before UTF-8 support was
+ sequences retain their original meanings from before UTF support was
available, mainly for efficiency reasons. However, if PCRE is compiled
with Unicode property support, and the PCRE_UCP option is set, the be-
haviour is changed so that Unicode properties are used to determine
@@ -3776,8 +4218,8 @@ BACKSLASH
The sequences \h, \H, \v, and \V are features that were added to Perl
at release 5.10. In contrast to the other sequences, which match only
ASCII characters by default, these always match certain high-valued
- codepoints in UTF-8 mode, whether or not PCRE_UCP is set. The horizon-
- tal space characters are:
+ codepoints, whether or not PCRE_UCP is set. The horizontal space char-
+ acters are:
U+0009 Horizontal tab
U+0020 Space
@@ -3809,106 +4251,109 @@ BACKSLASH
U+2028 Line separator
U+2029 Paragraph separator
+ In 8-bit, non-UTF-8 mode, only the characters with codepoints less than
+ 256 are relevant.
+
Newline sequences
- Outside a character class, by default, the escape sequence \R matches
- any Unicode newline sequence. In non-UTF-8 mode \R is equivalent to the
- following:
+ Outside a character class, by default, the escape sequence \R matches
+ any Unicode newline sequence. In 8-bit non-UTF-8 mode \R is equivalent
+ to the following:
(?>\r\n|\n|\x0b|\f|\r|\x85)
- This is an example of an "atomic group", details of which are given
+ This is an example of an "atomic group", details of which are given
below. This particular group matches either the two-character sequence
- CR followed by LF, or one of the single characters LF (linefeed,
+ CR followed by LF, or one of the single characters LF (linefeed,
U+000A), VT (vertical tab, U+000B), FF (formfeed, U+000C), CR (carriage
return, U+000D), or NEL (next line, U+0085). The two-character sequence
is treated as a single unit that cannot be split.
- In UTF-8 mode, two additional characters whose codepoints are greater
+ In other modes, two additional characters whose codepoints are greater
than 255 are added: LS (line separator, U+2028) and PS (paragraph sepa-
- rator, U+2029). Unicode character property support is not needed for
+ rator, U+2029). Unicode character property support is not needed for
these characters to be recognized.
It is possible to restrict \R to match only CR, LF, or CRLF (instead of
- the complete set of Unicode line endings) by setting the option
+ the complete set of Unicode line endings) by setting the option
PCRE_BSR_ANYCRLF either at compile time or when the pattern is matched.
(BSR is an abbrevation for "backslash R".) This can be made the default
- when PCRE is built; if this is the case, the other behaviour can be
- requested via the PCRE_BSR_UNICODE option. It is also possible to
- specify these settings by starting a pattern string with one of the
+ when PCRE is built; if this is the case, the other behaviour can be
+ requested via the PCRE_BSR_UNICODE option. It is also possible to
+ specify these settings by starting a pattern string with one of the
following sequences:
(*BSR_ANYCRLF) CR, LF, or CRLF only
(*BSR_UNICODE) any Unicode newline sequence
- These override the default and the options given to pcre_compile() or
- pcre_compile2(), but they can be overridden by options given to
- pcre_exec() or pcre_dfa_exec(). Note that these special settings, which
- are not Perl-compatible, are recognized only at the very start of a
- pattern, and that they must be in upper case. If more than one of them
- is present, the last one is used. They can be combined with a change of
+ These override the default and the options given to the compiling func-
+ tion, but they can themselves be overridden by options given to a
+ matching function. Note that these special settings, which are not
+ Perl-compatible, are recognized only at the very start of a pattern,
+ and that they must be in upper case. If more than one of them is
+ present, the last one is used. They can be combined with a change of
newline convention; for example, a pattern can start with:
(*ANY)(*BSR_ANYCRLF)
- They can also be combined with the (*UTF8) or (*UCP) special sequences.
- Inside a character class, \R is treated as an unrecognized escape
- sequence, and so matches the letter "R" by default, but causes an error
- if PCRE_EXTRA is set.
+ They can also be combined with the (*UTF8), (*UTF16), or (*UCP) special
+ sequences. Inside a character class, \R is treated as an unrecognized
+ escape sequence, and so matches the letter "R" by default, but causes
+ an error if PCRE_EXTRA is set.
Unicode character properties
When PCRE is built with Unicode character property support, three addi-
- tional escape sequences that match characters with specific properties
- are available. When not in UTF-8 mode, these sequences are of course
- limited to testing characters whose codepoints are less than 256, but
- they do work in this mode. The extra escape sequences are:
+ tional escape sequences that match characters with specific properties
+ are available. When in 8-bit non-UTF-8 mode, these sequences are of
+ course limited to testing characters whose codepoints are less than
+ 256, but they do work in this mode. The extra escape sequences are:
\p{xx} a character with the xx property
\P{xx} a character without the xx property
\X an extended Unicode sequence
- The property names represented by xx above are limited to the Unicode
+ The property names represented by xx above are limited to the Unicode
script names, the general category properties, "Any", which matches any
- character (including newline), and some special PCRE properties
- (described in the next section). Other Perl properties such as "InMu-
- sicalSymbols" are not currently supported by PCRE. Note that \P{Any}
+ character (including newline), and some special PCRE properties
+ (described in the next section). Other Perl properties such as "InMu-
+ sicalSymbols" are not currently supported by PCRE. Note that \P{Any}
does not match any characters, so always causes a match failure.
Sets of Unicode characters are defined as belonging to certain scripts.
- A character from one of these sets can be matched using a script name.
+ A character from one of these sets can be matched using a script name.
For example:
\p{Greek}
\P{Han}
- Those that are not part of an identified script are lumped together as
+ Those that are not part of an identified script are lumped together as
"Common". The current list of scripts is:
Arabic, Armenian, Avestan, Balinese, Bamum, Bengali, Bopomofo, Braille,
- Buginese, Buhid, Canadian_Aboriginal, Carian, Cham, Cherokee, Common,
- Coptic, Cuneiform, Cypriot, Cyrillic, Deseret, Devanagari, Egyp-
- tian_Hieroglyphs, Ethiopic, Georgian, Glagolitic, Gothic, Greek,
- Gujarati, Gurmukhi, Han, Hangul, Hanunoo, Hebrew, Hiragana, Impe-
+ Buginese, Buhid, Canadian_Aboriginal, Carian, Cham, Cherokee, Common,
+ Coptic, Cuneiform, Cypriot, Cyrillic, Deseret, Devanagari, Egyp-
+ tian_Hieroglyphs, Ethiopic, Georgian, Glagolitic, Gothic, Greek,
+ Gujarati, Gurmukhi, Han, Hangul, Hanunoo, Hebrew, Hiragana, Impe-
rial_Aramaic, Inherited, Inscriptional_Pahlavi, Inscriptional_Parthian,
- Javanese, Kaithi, Kannada, Katakana, Kayah_Li, Kharoshthi, Khmer, Lao,
+ Javanese, Kaithi, Kannada, Katakana, Kayah_Li, Kharoshthi, Khmer, Lao,
Latin, Lepcha, Limbu, Linear_B, Lisu, Lycian, Lydian, Malayalam,
- Meetei_Mayek, Mongolian, Myanmar, New_Tai_Lue, Nko, Ogham, Old_Italic,
- Old_Persian, Old_South_Arabian, Old_Turkic, Ol_Chiki, Oriya, Osmanya,
- Phags_Pa, Phoenician, Rejang, Runic, Samaritan, Saurashtra, Shavian,
- Sinhala, Sundanese, Syloti_Nagri, Syriac, Tagalog, Tagbanwa, Tai_Le,
- Tai_Tham, Tai_Viet, Tamil, Telugu, Thaana, Thai, Tibetan, Tifinagh,
+ Meetei_Mayek, Mongolian, Myanmar, New_Tai_Lue, Nko, Ogham, Old_Italic,
+ Old_Persian, Old_South_Arabian, Old_Turkic, Ol_Chiki, Oriya, Osmanya,
+ Phags_Pa, Phoenician, Rejang, Runic, Samaritan, Saurashtra, Shavian,
+ Sinhala, Sundanese, Syloti_Nagri, Syriac, Tagalog, Tagbanwa, Tai_Le,
+ Tai_Tham, Tai_Viet, Tamil, Telugu, Thaana, Thai, Tibetan, Tifinagh,
Ugaritic, Vai, Yi.
Each character has exactly one Unicode general category property, spec-
- ified by a two-letter abbreviation. For compatibility with Perl, nega-
- tion can be specified by including a circumflex between the opening
- brace and the property name. For example, \p{^Lu} is the same as
+ ified by a two-letter abbreviation. For compatibility with Perl, nega-
+ tion can be specified by including a circumflex between the opening
+ brace and the property name. For example, \p{^Lu} is the same as
\P{Lu}.
If only one letter is specified with \p or \P, it includes all the gen-
- eral category properties that start with that letter. In this case, in
- the absence of negation, the curly brackets in the escape sequence are
+ eral category properties that start with that letter. In this case, in
+ the absence of negation, the curly brackets in the escape sequence are
optional; these two examples have the same effect:
\p{L}
@@ -3960,15 +4405,16 @@ BACKSLASH
Zp Paragraph separator
Zs Space separator
- The special property L& is also supported: it matches a character that
- has the Lu, Ll, or Lt property, in other words, a letter that is not
+ The special property L& is also supported: it matches a character that
+ has the Lu, Ll, or Lt property, in other words, a letter that is not
classified as a modifier or "other".
- The Cs (Surrogate) property applies only to characters in the range
- U+D800 to U+DFFF. Such characters are not valid in UTF-8 strings (see
- RFC 3629) and so cannot be tested by PCRE, unless UTF-8 validity check-
- ing has been turned off (see the discussion of PCRE_NO_UTF8_CHECK in
- the pcreapi page). Perl does not support the Cs property.
+ The Cs (Surrogate) property applies only to characters in the range
+ U+D800 to U+DFFF. Such characters are not valid in Unicode strings and
+ so cannot be tested by PCRE, unless UTF validity checking has been
+ turned off (see the discussion of PCRE_NO_UTF8_CHECK and
+ PCRE_NO_UTF16_CHECK in the pcreapi page). Perl does not support the Cs
+ property.
The long synonyms for property names that Perl supports (such as
\p{Letter}) are not supported by PCRE, nor is it permitted to prefix
@@ -3990,8 +4436,8 @@ BACKSLASH
by zero or more characters with the "mark" property, and treats the
sequence as an atomic group (see below). Characters with the "mark"
property are typically accents that affect the preceding character.
- None of them have codepoints less than 256, so in non-UTF-8 mode \X
- matches any one character.
+ None of them have codepoints less than 256, so in 8-bit non-UTF-8 mode
+ \X matches any one character.
Note that recent versions of Perl have changed \X to match what Unicode
calls an "extended grapheme cluster", which has a more complicated def-
@@ -4001,8 +4447,8 @@ BACKSLASH
to search a structure that contains data for over fifteen thousand
characters. That is why the traditional escape sequences such as \d and
\w do not use Unicode properties in PCRE by default, though you can
- make them do so by setting the PCRE_UCP option for pcre_compile() or by
- starting the pattern with (*UCP).
+ make them do so by setting the PCRE_UCP option or by starting the pat-
+ tern with (*UCP).
PCRE's additional properties
@@ -4071,8 +4517,8 @@ BACKSLASH
A word boundary is a position in the subject string where the current
character and the previous character do not both match \w or \W (i.e.
one matches \w and the other matches \W), or the start or end of the
- string if the first or last character matches \w, respectively. In
- UTF-8 mode, the meanings of \w and \W can be changed by setting the
+ string if the first or last character matches \w, respectively. In a
+ UTF mode, the meanings of \w and \W can be changed by setting the
PCRE_UCP option. When this is done, it also affects \b and \B. Neither
PCRE nor Perl has a separate "start of word" or "end of word" metase-
quence. However, whatever follows \b normally determines which it is.
@@ -4163,63 +4609,64 @@ FULL STOP (PERIOD, DOT) AND \N
Outside a character class, a dot in the pattern matches any one charac-
ter in the subject string except (by default) a character that signi-
- fies the end of a line. In UTF-8 mode, the matched character may be
- more than one byte long.
-
- When a line ending is defined as a single character, dot never matches
- that character; when the two-character sequence CRLF is used, dot does
- not match CR if it is immediately followed by LF, but otherwise it
- matches all characters (including isolated CRs and LFs). When any Uni-
- code line endings are being recognized, dot does not match CR or LF or
+ fies the end of a line.
+
+ When a line ending is defined as a single character, dot never matches
+ that character; when the two-character sequence CRLF is used, dot does
+ not match CR if it is immediately followed by LF, but otherwise it
+ matches all characters (including isolated CRs and LFs). When any Uni-
+ code line endings are being recognized, dot does not match CR or LF or
any of the other line ending characters.
- The behaviour of dot with regard to newlines can be changed. If the
- PCRE_DOTALL option is set, a dot matches any one character, without
+ The behaviour of dot with regard to newlines can be changed. If the
+ PCRE_DOTALL option is set, a dot matches any one character, without
exception. If the two-character sequence CRLF is present in the subject
string, it takes two dots to match it.
- The handling of dot is entirely independent of the handling of circum-
- flex and dollar, the only relationship being that they both involve
+ The handling of dot is entirely independent of the handling of circum-
+ flex and dollar, the only relationship being that they both involve
newlines. Dot has no special meaning in a character class.
- The escape sequence \N behaves like a dot, except that it is not
- affected by the PCRE_DOTALL option. In other words, it matches any
- character except one that signifies the end of a line. Perl also uses
+ The escape sequence \N behaves like a dot, except that it is not
+ affected by the PCRE_DOTALL option. In other words, it matches any
+ character except one that signifies the end of a line. Perl also uses
\N to match characters by name; PCRE does not support this.
-MATCHING A SINGLE BYTE
+MATCHING A SINGLE DATA UNIT
- Outside a character class, the escape sequence \C matches any one byte,
- both in and out of UTF-8 mode. Unlike a dot, it always matches line-
- ending characters. The feature is provided in Perl in order to match
- individual bytes in UTF-8 mode, but it is unclear how it can usefully
- be used. Because \C breaks up characters into individual bytes, match-
- ing one byte with \C in UTF-8 mode means that the rest of the string
- may start with a malformed UTF-8 character. This has undefined results,
- because PCRE assumes that it is dealing with valid UTF-8 strings (and
- by default it checks this at the start of processing unless the
- PCRE_NO_UTF8_CHECK option is used).
+ Outside a character class, the escape sequence \C matches any one data
+ unit, whether or not a UTF mode is set. In the 8-bit library, one data
+ unit is one byte; in the 16-bit library it is a 16-bit unit. Unlike a
+ dot, \C always matches line-ending characters. The feature is provided
+ in Perl in order to match individual bytes in UTF-8 mode, but it is
+ unclear how it can usefully be used. Because \C breaks up characters
+ into individual data units, matching one unit with \C in a UTF mode
+ means that the rest of the string may start with a malformed UTF char-
+ acter. This has undefined results, because PCRE assumes that it is
+ dealing with valid UTF strings (and by default it checks this at the
+ start of processing unless the PCRE_NO_UTF8_CHECK option is used).
PCRE does not allow \C to appear in lookbehind assertions (described
- below) in UTF-8 mode, because this would make it impossible to calcu-
+ below) in a UTF mode, because this would make it impossible to calcu-
late the length of the lookbehind.
- In general, the \C escape sequence is best avoided in UTF-8 mode. How-
- ever, one way of using it that avoids the problem of malformed UTF-8
- characters is to use a lookahead to check the length of the next char-
- acter, as in this pattern (ignore white space and line breaks):
+ In general, the \C escape sequence is best avoided. However, one way of
+ using it that avoids the problem of malformed UTF characters is to use
+ a lookahead to check the length of the next character, as in this pat-
+ tern, which could be used with a UTF-8 string (ignore white space and
+ line breaks):
(?| (?=[\x00-\x7f])(\C) |
(?=[\x80-\x{7ff}])(\C)(\C) |
(?=[\x{800}-\x{ffff}])(\C)(\C)(\C) |
(?=[\x{10000}-\x{1fffff}])(\C)(\C)(\C)(\C))
- A group that starts with (?| resets the capturing parentheses numbers
- in each alternative (see "Duplicate Subpattern Numbers" below). The
- assertions at the start of each branch check the next UTF-8 character
- for values whose encoding uses 1, 2, 3, or 4 bytes, respectively. The
- character's individual bytes are then captured by the appropriate num-
+ A group that starts with (?| resets the capturing parentheses numbers
+ in each alternative (see "Duplicate Subpattern Numbers" below). The
+ assertions at the start of each branch check the next UTF-8 character
+ for values whose encoding uses 1, 2, 3, or 4 bytes, respectively. The
+ character's individual bytes are then captured by the appropriate num-
ber of groups.
@@ -4229,109 +4676,109 @@ SQUARE BRACKETS AND CHARACTER CLASSES
closing square bracket. A closing square bracket on its own is not spe-
cial by default. However, if the PCRE_JAVASCRIPT_COMPAT option is set,
a lone closing square bracket causes a compile-time error. If a closing
- square bracket is required as a member of the class, it should be the
- first data character in the class (after an initial circumflex, if
+ square bracket is required as a member of the class, it should be the
+ first data character in the class (after an initial circumflex, if
present) or escaped with a backslash.
- A character class matches a single character in the subject. In UTF-8
- mode, the character may be more than one byte long. A matched character
- must be in the set of characters defined by the class, unless the first
- character in the class definition is a circumflex, in which case the
- subject character must not be in the set defined by the class. If a
- circumflex is actually required as a member of the class, ensure it is
- not the first character, or escape it with a backslash.
+ A character class matches a single character in the subject. In a UTF
+ mode, the character may be more than one data unit long. A matched
+ character must be in the set of characters defined by the class, unless
+ the first character in the class definition is a circumflex, in which
+ case the subject character must not be in the set defined by the class.
+ If a circumflex is actually required as a member of the class, ensure
+ it is not the first character, or escape it with a backslash.
- For example, the character class [aeiou] matches any lower case vowel,
- while [^aeiou] matches any character that is not a lower case vowel.
+ For example, the character class [aeiou] matches any lower case vowel,
+ while [^aeiou] matches any character that is not a lower case vowel.
Note that a circumflex is just a convenient notation for specifying the
- characters that are in the class by enumerating those that are not. A
- class that starts with a circumflex is not an assertion; it still con-
- sumes a character from the subject string, and therefore it fails if
+ characters that are in the class by enumerating those that are not. A
+ class that starts with a circumflex is not an assertion; it still con-
+ sumes a character from the subject string, and therefore it fails if
the current pointer is at the end of the string.
- In UTF-8 mode, characters with values greater than 255 can be included
- in a class as a literal string of bytes, or by using the \x{ escaping
- mechanism.
-
- When caseless matching is set, any letters in a class represent both
- their upper case and lower case versions, so for example, a caseless
- [aeiou] matches "A" as well as "a", and a caseless [^aeiou] does not
- match "A", whereas a caseful version would. In UTF-8 mode, PCRE always
- understands the concept of case for characters whose values are less
- than 128, so caseless matching is always possible. For characters with
- higher values, the concept of case is supported if PCRE is compiled
- with Unicode property support, but not otherwise. If you want to use
- caseless matching in UTF8-mode for characters 128 and above, you must
- ensure that PCRE is compiled with Unicode property support as well as
- with UTF-8 support.
-
- Characters that might indicate line breaks are never treated in any
- special way when matching character classes, whatever line-ending
- sequence is in use, and whatever setting of the PCRE_DOTALL and
+ In UTF-8 (UTF-16) mode, characters with values greater than 255
+ (0xffff) can be included in a class as a literal string of data units,
+ or by using the \x{ escaping mechanism.
+
+ When caseless matching is set, any letters in a class represent both
+ their upper case and lower case versions, so for example, a caseless
+ [aeiou] matches "A" as well as "a", and a caseless [^aeiou] does not
+ match "A", whereas a caseful version would. In a UTF mode, PCRE always
+ understands the concept of case for characters whose values are less
+ than 128, so caseless matching is always possible. For characters with
+ higher values, the concept of case is supported if PCRE is compiled
+ with Unicode property support, but not otherwise. If you want to use
+ caseless matching in a UTF mode for characters 128 and above, you must
+ ensure that PCRE is compiled with Unicode property support as well as
+ with UTF support.
+
+ Characters that might indicate line breaks are never treated in any
+ special way when matching character classes, whatever line-ending
+ sequence is in use, and whatever setting of the PCRE_DOTALL and
PCRE_MULTILINE options is used. A class such as [^a] always matches one
of these characters.
- The minus (hyphen) character can be used to specify a range of charac-
- ters in a character class. For example, [d-m] matches any letter
- between d and m, inclusive. If a minus character is required in a
- class, it must be escaped with a backslash or appear in a position
- where it cannot be interpreted as indicating a range, typically as the
+ The minus (hyphen) character can be used to specify a range of charac-
+ ters in a character class. For example, [d-m] matches any letter
+ between d and m, inclusive. If a minus character is required in a
+ class, it must be escaped with a backslash or appear in a position
+ where it cannot be interpreted as indicating a range, typically as the
first or last character in the class.
It is not possible to have the literal character "]" as the end charac-
- ter of a range. A pattern such as [W-]46] is interpreted as a class of
- two characters ("W" and "-") followed by a literal string "46]", so it
- would match "W46]" or "-46]". However, if the "]" is escaped with a
- backslash it is interpreted as the end of range, so [W-\]46] is inter-
- preted as a class containing a range followed by two other characters.
- The octal or hexadecimal representation of "]" can also be used to end
+ ter of a range. A pattern such as [W-]46] is interpreted as a class of
+ two characters ("W" and "-") followed by a literal string "46]", so it
+ would match "W46]" or "-46]". However, if the "]" is escaped with a
+ backslash it is interpreted as the end of range, so [W-\]46] is inter-
+ preted as a class containing a range followed by two other characters.
+ The octal or hexadecimal representation of "]" can also be used to end
a range.
- Ranges operate in the collating sequence of character values. They can
- also be used for characters specified numerically, for example
- [\000-\037]. In UTF-8 mode, ranges can include characters whose values
- are greater than 255, for example [\x{100}-\x{2ff}].
+ Ranges operate in the collating sequence of character values. They can
+ also be used for characters specified numerically, for example
+ [\000-\037]. Ranges can include any characters that are valid for the
+ current mode.
If a range that includes letters is used when caseless matching is set,
it matches the letters in either case. For example, [W-c] is equivalent
- to [][\\^_`wxyzabc], matched caselessly, and in non-UTF-8 mode, if
- character tables for a French locale are in use, [\xc8-\xcb] matches
- accented E characters in both cases. In UTF-8 mode, PCRE supports the
- concept of case for characters with values greater than 128 only when
+ to [][\\^_`wxyzabc], matched caselessly, and in a non-UTF mode, if
+ character tables for a French locale are in use, [\xc8-\xcb] matches
+ accented E characters in both cases. In UTF modes, PCRE supports the
+ concept of case for characters with values greater than 128 only when
it is compiled with Unicode property support.
- The character escape sequences \d, \D, \h, \H, \p, \P, \s, \S, \v, \V,
+ The character escape sequences \d, \D, \h, \H, \p, \P, \s, \S, \v, \V,
\w, and \W may appear in a character class, and add the characters that
- they match to the class. For example, [\dABCDEF] matches any hexadeci-
- mal digit. In UTF-8 mode, the PCRE_UCP option affects the meanings of
- \d, \s, \w and their upper case partners, just as it does when they
- appear outside a character class, as described in the section entitled
+ they match to the class. For example, [\dABCDEF] matches any hexadeci-
+ mal digit. In UTF modes, the PCRE_UCP option affects the meanings of
+ \d, \s, \w and their upper case partners, just as it does when they
+ appear outside a character class, as described in the section entitled
"Generic character types" above. The escape sequence \b has a different
- meaning inside a character class; it matches the backspace character.
- The sequences \B, \N, \R, and \X are not special inside a character
- class. Like any other unrecognized escape sequences, they are treated
- as the literal characters "B", "N", "R", and "X" by default, but cause
+ meaning inside a character class; it matches the backspace character.
+ The sequences \B, \N, \R, and \X are not special inside a character
+ class. Like any other unrecognized escape sequences, they are treated
+ as the literal characters "B", "N", "R", and "X" by default, but cause
an error if the PCRE_EXTRA option is set.
- A circumflex can conveniently be used with the upper case character
- types to specify a more restricted set of characters than the matching
- lower case type. For example, the class [^\W_] matches any letter or
+ A circumflex can conveniently be used with the upper case character
+ types to specify a more restricted set of characters than the matching
+ lower case type. For example, the class [^\W_] matches any letter or
digit, but not underscore, whereas [\w] includes underscore. A positive
character class should be read as "something OR something OR ..." and a
negative class as "NOT something AND NOT something AND NOT ...".
- The only metacharacters that are recognized in character classes are
- backslash, hyphen (only where it can be interpreted as specifying a
- range), circumflex (only at the start), opening square bracket (only
- when it can be interpreted as introducing a POSIX class name - see the
- next section), and the terminating closing square bracket. However,
+ The only metacharacters that are recognized in character classes are
+ backslash, hyphen (only where it can be interpreted as specifying a
+ range), circumflex (only at the start), opening square bracket (only
+ when it can be interpreted as introducing a POSIX class name - see the
+ next section), and the terminating closing square bracket. However,
escaping other non-alphanumeric characters does no harm.
POSIX CHARACTER CLASSES
Perl supports the POSIX notation for character classes. This uses names
- enclosed by [: and :] within the enclosing square brackets. PCRE also
+ enclosed by [: and :] within the enclosing square brackets. PCRE also
supports this notation. For example,
[01[:alpha:]%]
@@ -4354,24 +4801,24 @@ POSIX CHARACTER CLASSES
word "word" characters (same as \w)
xdigit hexadecimal digits
- The "space" characters are HT (9), LF (10), VT (11), FF (12), CR (13),
- and space (32). Notice that this list includes the VT character (code
+ The "space" characters are HT (9), LF (10), VT (11), FF (12), CR (13),
+ and space (32). Notice that this list includes the VT character (code
11). This makes "space" different to \s, which does not include VT (for
Perl compatibility).
- The name "word" is a Perl extension, and "blank" is a GNU extension
- from Perl 5.8. Another Perl extension is negation, which is indicated
+ The name "word" is a Perl extension, and "blank" is a GNU extension
+ from Perl 5.8. Another Perl extension is negation, which is indicated
by a ^ character after the colon. For example,
[12[:^digit:]]
- matches "1", "2", or any non-digit. PCRE (and Perl) also recognize the
+ matches "1", "2", or any non-digit. PCRE (and Perl) also recognize the
POSIX syntax [.ch.] and [=ch=] where "ch" is a "collating element", but
these are not supported, and an error is given if they are encountered.
- By default, in UTF-8 mode, characters with values greater than 128 do
- not match any of the POSIX character classes. However, if the PCRE_UCP
- option is passed to pcre_compile(), some of the classes are changed so
+ By default, in UTF modes, characters with values greater than 128 do
+ not match any of the POSIX character classes. However, if the PCRE_UCP
+ option is passed to pcre_compile(), some of the classes are changed so
that Unicode character properties are used. This is achieved by replac-
ing the POSIX classes by other sequences, as follows:
@@ -4384,31 +4831,31 @@ POSIX CHARACTER CLASSES
[:upper:] becomes \p{Lu}
[:word:] becomes \p{Xwd}
- Negated versions, such as [:^alpha:] use \P instead of \p. The other
+ Negated versions, such as [:^alpha:] use \P instead of \p. The other
POSIX classes are unchanged, and match only characters with code points
less than 128.
VERTICAL BAR
- Vertical bar characters are used to separate alternative patterns. For
+ Vertical bar characters are used to separate alternative patterns. For
example, the pattern
gilbert|sullivan
- matches either "gilbert" or "sullivan". Any number of alternatives may
- appear, and an empty alternative is permitted (matching the empty
+ matches either "gilbert" or "sullivan". Any number of alternatives may
+ appear, and an empty alternative is permitted (matching the empty
string). The matching process tries each alternative in turn, from left
- to right, and the first one that succeeds is used. If the alternatives
- are within a subpattern (defined below), "succeeds" means matching the
+ to right, and the first one that succeeds is used. If the alternatives
+ are within a subpattern (defined below), "succeeds" means matching the
rest of the main pattern as well as the alternative in the subpattern.
INTERNAL OPTION SETTING
- The settings of the PCRE_CASELESS, PCRE_MULTILINE, PCRE_DOTALL, and
- PCRE_EXTENDED options (which are Perl-compatible) can be changed from
- within the pattern by a sequence of Perl option letters enclosed
+ The settings of the PCRE_CASELESS, PCRE_MULTILINE, PCRE_DOTALL, and
+ PCRE_EXTENDED options (which are Perl-compatible) can be changed from
+ within the pattern by a sequence of Perl option letters enclosed
between "(?" and ")". The option letters are
i for PCRE_CASELESS
@@ -4418,48 +4865,49 @@ INTERNAL OPTION SETTING
For example, (?im) sets caseless, multiline matching. It is also possi-
ble to unset these options by preceding the letter with a hyphen, and a
- combined setting and unsetting such as (?im-sx), which sets PCRE_CASE-
- LESS and PCRE_MULTILINE while unsetting PCRE_DOTALL and PCRE_EXTENDED,
- is also permitted. If a letter appears both before and after the
+ combined setting and unsetting such as (?im-sx), which sets PCRE_CASE-
+ LESS and PCRE_MULTILINE while unsetting PCRE_DOTALL and PCRE_EXTENDED,
+ is also permitted. If a letter appears both before and after the
hyphen, the option is unset.
- The PCRE-specific options PCRE_DUPNAMES, PCRE_UNGREEDY, and PCRE_EXTRA
- can be changed in the same way as the Perl-compatible options by using
+ The PCRE-specific options PCRE_DUPNAMES, PCRE_UNGREEDY, and PCRE_EXTRA
+ can be changed in the same way as the Perl-compatible options by using
the characters J, U and X respectively.
- When one of these option changes occurs at top level (that is, not
- inside subpattern parentheses), the change applies to the remainder of
+ When one of these option changes occurs at top level (that is, not
+ inside subpattern parentheses), the change applies to the remainder of
the pattern that follows. If the change is placed right at the start of
a pattern, PCRE extracts it into the global options (and it will there-
fore show up in data extracted by the pcre_fullinfo() function).
- An option change within a subpattern (see below for a description of
- subpatterns) affects only that part of the subpattern that follows it,
+ An option change within a subpattern (see below for a description of
+ subpatterns) affects only that part of the subpattern that follows it,
so
(a(?i)b)c
matches abc and aBc and no other strings (assuming PCRE_CASELESS is not
- used). By this means, options can be made to have different settings
- in different parts of the pattern. Any changes made in one alternative
- do carry on into subsequent branches within the same subpattern. For
+ used). By this means, options can be made to have different settings
+ in different parts of the pattern. Any changes made in one alternative
+ do carry on into subsequent branches within the same subpattern. For
example,
(a(?i)b|c)
- matches "ab", "aB", "c", and "C", even though when matching "C" the
- first branch is abandoned before the option setting. This is because
- the effects of option settings happen at compile time. There would be
+ matches "ab", "aB", "c", and "C", even though when matching "C" the
+ first branch is abandoned before the option setting. This is because
+ the effects of option settings happen at compile time. There would be
some very weird behaviour otherwise.
- Note: There are other PCRE-specific options that can be set by the
- application when the compile or match functions are called. In some
- cases the pattern can contain special leading sequences such as (*CRLF)
- to override what the application has set or what has been defaulted.
- Details are given in the section entitled "Newline sequences" above.
- There are also the (*UTF8) and (*UCP) leading sequences that can be
- used to set UTF-8 and Unicode property modes; they are equivalent to
- setting the PCRE_UTF8 and the PCRE_UCP options, respectively.
+ Note: There are other PCRE-specific options that can be set by the
+ application when the compiling or matching functions are called. In
+ some cases the pattern can contain special leading sequences such as
+ (*CRLF) to override what the application has set or what has been
+ defaulted. Details are given in the section entitled "Newline
+ sequences" above. There are also the (*UTF8), (*UTF16), and (*UCP)
+ leading sequences that can be used to set UTF and Unicode property
+ modes; they are equivalent to setting the PCRE_UTF8, PCRE_UTF16, and
+ the PCRE_UCP options, respectively.
SUBPATTERNS
@@ -4477,22 +4925,25 @@ SUBPATTERNS
2. It sets up the subpattern as a capturing subpattern. This means
that, when the whole pattern matches, that portion of the subject
string that matched the subpattern is passed back to the caller via the
- ovector argument of pcre_exec(). Opening parentheses are counted from
- left to right (starting from 1) to obtain numbers for the capturing
- subpatterns. For example, if the string "the red king" is matched
- against the pattern
+ ovector argument of the matching function. (This applies only to the
+ traditional matching functions; the DFA matching functions do not sup-
+ port capturing.)
+
+ Opening parentheses are counted from left to right (starting from 1) to
+ obtain numbers for the capturing subpatterns. For example, if the
+ string "the red king" is matched against the pattern
the ((red|white) (king|queen))
the captured substrings are "red king", "red", and "king", and are num-
bered 1, 2, and 3, respectively.
- The fact that plain parentheses fulfil two functions is not always
- helpful. There are often times when a grouping subpattern is required
- without a capturing requirement. If an opening parenthesis is followed
- by a question mark and a colon, the subpattern does not do any captur-
- ing, and is not counted when computing the number of any subsequent
- capturing subpatterns. For example, if the string "the white queen" is
+ The fact that plain parentheses fulfil two functions is not always
+ helpful. There are often times when a grouping subpattern is required
+ without a capturing requirement. If an opening parenthesis is followed
+ by a question mark and a colon, the subpattern does not do any captur-
+ ing, and is not counted when computing the number of any subsequent
+ capturing subpatterns. For example, if the string "the white queen" is
matched against the pattern
the ((?:red|white) (king|queen))
@@ -4500,37 +4951,37 @@ SUBPATTERNS
the captured substrings are "white queen" and "queen", and are numbered
1 and 2. The maximum number of capturing subpatterns is 65535.
- As a convenient shorthand, if any option settings are required at the
- start of a non-capturing subpattern, the option letters may appear
+ As a convenient shorthand, if any option settings are required at the
+ start of a non-capturing subpattern, the option letters may appear
between the "?" and the ":". Thus the two patterns
(?i:saturday|sunday)
(?:(?i)saturday|sunday)
match exactly the same set of strings. Because alternative branches are
- tried from left to right, and options are not reset until the end of
- the subpattern is reached, an option setting in one branch does affect
- subsequent branches, so the above patterns match "SUNDAY" as well as
+ tried from left to right, and options are not reset until the end of
+ the subpattern is reached, an option setting in one branch does affect
+ subsequent branches, so the above patterns match "SUNDAY" as well as
"Saturday".
DUPLICATE SUBPATTERN NUMBERS
Perl 5.10 introduced a feature whereby each alternative in a subpattern
- uses the same numbers for its capturing parentheses. Such a subpattern
- starts with (?| and is itself a non-capturing subpattern. For example,
+ uses the same numbers for its capturing parentheses. Such a subpattern
+ starts with (?| and is itself a non-capturing subpattern. For example,
consider this pattern:
(?|(Sat)ur|(Sun))day
- Because the two alternatives are inside a (?| group, both sets of cap-
- turing parentheses are numbered one. Thus, when the pattern matches,
- you can look at captured substring number one, whichever alternative
- matched. This construct is useful when you want to capture part, but
+ Because the two alternatives are inside a (?| group, both sets of cap-
+ turing parentheses are numbered one. Thus, when the pattern matches,
+ you can look at captured substring number one, whichever alternative
+ matched. This construct is useful when you want to capture part, but
not all, of one of a number of alternatives. Inside a (?| group, paren-
- theses are numbered as usual, but the number is reset at the start of
- each branch. The numbers of any capturing parentheses that follow the
- subpattern start after the highest number used in any branch. The fol-
+ theses are numbered as usual, but the number is reset at the start of
+ each branch. The numbers of any capturing parentheses that follow the
+ subpattern start after the highest number used in any branch. The fol-
lowing example is taken from the Perl documentation. The numbers under-
neath show in which buffer the captured content will be stored.
@@ -4538,58 +4989,58 @@ DUPLICATE SUBPATTERN NUMBERS
/ ( a ) (?| x ( y ) z | (p (q) r) | (t) u (v) ) ( z ) /x
# 1 2 2 3 2 3 4
- A back reference to a numbered subpattern uses the most recent value
- that is set for that number by any subpattern. The following pattern
+ A back reference to a numbered subpattern uses the most recent value
+ that is set for that number by any subpattern. The following pattern
matches "abcabc" or "defdef":
/(?|(abc)|(def))\1/
- In contrast, a subroutine call to a numbered subpattern always refers
- to the first one in the pattern with the given number. The following
+ In contrast, a subroutine call to a numbered subpattern always refers
+ to the first one in the pattern with the given number. The following
pattern matches "abcabc" or "defabc":
/(?|(abc)|(def))(?1)/
- If a condition test for a subpattern's having matched refers to a non-
- unique number, the test is true if any of the subpatterns of that num-
+ If a condition test for a subpattern's having matched refers to a non-
+ unique number, the test is true if any of the subpatterns of that num-
ber have matched.
- An alternative approach to using this "branch reset" feature is to use
+ An alternative approach to using this "branch reset" feature is to use
duplicate named subpatterns, as described in the next section.
NAMED SUBPATTERNS
- Identifying capturing parentheses by number is simple, but it can be
- very hard to keep track of the numbers in complicated regular expres-
- sions. Furthermore, if an expression is modified, the numbers may
- change. To help with this difficulty, PCRE supports the naming of sub-
+ Identifying capturing parentheses by number is simple, but it can be
+ very hard to keep track of the numbers in complicated regular expres-
+ sions. Furthermore, if an expression is modified, the numbers may
+ change. To help with this difficulty, PCRE supports the naming of sub-
patterns. This feature was not added to Perl until release 5.10. Python
- had the feature earlier, and PCRE introduced it at release 4.0, using
- the Python syntax. PCRE now supports both the Perl and the Python syn-
- tax. Perl allows identically numbered subpatterns to have different
+ had the feature earlier, and PCRE introduced it at release 4.0, using
+ the Python syntax. PCRE now supports both the Perl and the Python syn-
+ tax. Perl allows identically numbered subpatterns to have different
names, but PCRE does not.
- In PCRE, a subpattern can be named in one of three ways: (?<name>...)
- or (?'name'...) as in Perl, or (?P<name>...) as in Python. References
- to capturing parentheses from other parts of the pattern, such as back
- references, recursion, and conditions, can be made by name as well as
+ In PCRE, a subpattern can be named in one of three ways: (?<name>...)
+ or (?'name'...) as in Perl, or (?P<name>...) as in Python. References
+ to capturing parentheses from other parts of the pattern, such as back
+ references, recursion, and conditions, can be made by name as well as
by number.
- Names consist of up to 32 alphanumeric characters and underscores.
- Named capturing parentheses are still allocated numbers as well as
- names, exactly as if the names were not present. The PCRE API provides
+ Names consist of up to 32 alphanumeric characters and underscores.
+ Named capturing parentheses are still allocated numbers as well as
+ names, exactly as if the names were not present. The PCRE API provides
function calls for extracting the name-to-number translation table from
a compiled pattern. There is also a convenience function for extracting
a captured substring by name.
- By default, a name must be unique within a pattern, but it is possible
+ By default, a name must be unique within a pattern, but it is possible
to relax this constraint by setting the PCRE_DUPNAMES option at compile
- time. (Duplicate names are also always permitted for subpatterns with
- the same number, set up as described in the previous section.) Dupli-
- cate names can be useful for patterns where only one instance of the
- named parentheses can match. Suppose you want to match the name of a
- weekday, either as a 3-letter abbreviation or as the full name, and in
+ time. (Duplicate names are also always permitted for subpatterns with
+ the same number, set up as described in the previous section.) Dupli-
+ cate names can be useful for patterns where only one instance of the
+ named parentheses can match. Suppose you want to match the name of a
+ weekday, either as a 3-letter abbreviation or as the full name, and in
both cases you want to extract the abbreviation. This pattern (ignoring
the line breaks) does the job:
@@ -4599,44 +5050,44 @@ NAMED SUBPATTERNS
(?<DN>Thu)(?:rsday)?|
(?<DN>Sat)(?:urday)?
- There are five capturing substrings, but only one is ever set after a
+ There are five capturing substrings, but only one is ever set after a
match. (An alternative way of solving this problem is to use a "branch
reset" subpattern, as described in the previous section.)
- The convenience function for extracting the data by name returns the
- substring for the first (and in this example, the only) subpattern of
- that name that matched. This saves searching to find which numbered
+ The convenience function for extracting the data by name returns the
+ substring for the first (and in this example, the only) subpattern of
+ that name that matched. This saves searching to find which numbered
subpattern it was.
- If you make a back reference to a non-unique named subpattern from
- elsewhere in the pattern, the one that corresponds to the first occur-
+ If you make a back reference to a non-unique named subpattern from
+ elsewhere in the pattern, the one that corresponds to the first occur-
rence of the name is used. In the absence of duplicate numbers (see the
- previous section) this is the one with the lowest number. If you use a
- named reference in a condition test (see the section about conditions
- below), either to check whether a subpattern has matched, or to check
- for recursion, all subpatterns with the same name are tested. If the
- condition is true for any one of them, the overall condition is true.
+ previous section) this is the one with the lowest number. If you use a
+ named reference in a condition test (see the section about conditions
+ below), either to check whether a subpattern has matched, or to check
+ for recursion, all subpatterns with the same name are tested. If the
+ condition is true for any one of them, the overall condition is true.
This is the same behaviour as testing by number. For further details of
the interfaces for handling named subpatterns, see the pcreapi documen-
tation.
Warning: You cannot use different names to distinguish between two sub-
- patterns with the same number because PCRE uses only the numbers when
+ patterns with the same number because PCRE uses only the numbers when
matching. For this reason, an error is given at compile time if differ-
- ent names are given to subpatterns with the same number. However, you
- can give the same name to subpatterns with the same number, even when
+ ent names are given to subpatterns with the same number. However, you
+ can give the same name to subpatterns with the same number, even when
PCRE_DUPNAMES is not set.
REPETITION
- Repetition is specified by quantifiers, which can follow any of the
+ Repetition is specified by quantifiers, which can follow any of the
following items:
a literal data character
the dot metacharacter
the \C escape sequence
- the \X escape sequence (in UTF-8 mode with Unicode properties)
+ the \X escape sequence
the \R escape sequence
an escape such as \d or \pL that matches a single character
a character class
@@ -4644,17 +5095,17 @@ REPETITION
a parenthesized subpattern (including assertions)
a subroutine call to a subpattern (recursive or otherwise)
- The general repetition quantifier specifies a minimum and maximum num-
- ber of permitted matches, by giving the two numbers in curly brackets
- (braces), separated by a comma. The numbers must be less than 65536,
+ The general repetition quantifier specifies a minimum and maximum num-
+ ber of permitted matches, by giving the two numbers in curly brackets
+ (braces), separated by a comma. The numbers must be less than 65536,
and the first must be less than or equal to the second. For example:
z{2,4}
- matches "zz", "zzz", or "zzzz". A closing brace on its own is not a
- special character. If the second number is omitted, but the comma is
- present, there is no upper limit; if the second number and the comma
- are both omitted, the quantifier specifies an exact number of required
+ matches "zz", "zzz", or "zzzz". A closing brace on its own is not a
+ special character. If the second number is omitted, but the comma is
+ present, there is no upper limit; if the second number and the comma
+ are both omitted, the quantifier specifies an exact number of required
matches. Thus
[aeiou]{3,}
@@ -4663,17 +5114,16 @@ REPETITION
\d{8}
- matches exactly 8 digits. An opening curly bracket that appears in a
- position where a quantifier is not allowed, or one that does not match
- the syntax of a quantifier, is taken as a literal character. For exam-
+ matches exactly 8 digits. An opening curly bracket that appears in a
+ position where a quantifier is not allowed, or one that does not match
+ the syntax of a quantifier, is taken as a literal character. For exam-
ple, {,6} is not a quantifier, but a literal string of four characters.
- In UTF-8 mode, quantifiers apply to UTF-8 characters rather than to
- individual bytes. Thus, for example, \x{100}{2} matches two UTF-8 char-
- acters, each of which is represented by a two-byte sequence. Similarly,
- when Unicode property support is available, \X{3} matches three Unicode
- extended sequences, each of which may be several bytes long (and they
- may be of different lengths).
+ In UTF modes, quantifiers apply to characters rather than to individual
+ data units. Thus, for example, \x{100}{2} matches two characters, each
+ of which is represented by a two-byte sequence in a UTF-8 string. Simi-
+ larly, \X{3} matches three Unicode extended sequences, each of which
+ may be several data units long (and they may be of different lengths).
The quantifier {0} is permitted, causing the expression to behave as if
the previous item and the quantifier were not present. This may be use-
@@ -5109,11 +5559,11 @@ ASSERTIONS
then try to match. If there are insufficient characters before the cur-
rent position, the assertion fails.
- In UTF-8 mode, PCRE does not allow the \C escape (which matches a sin-
- gle byte, even in UTF-8 mode) to appear in lookbehind assertions,
+ In a UTF mode, PCRE does not allow the \C escape (which matches a sin-
+ gle data unit even in a UTF mode) to appear in lookbehind assertions,
because it makes it impossible to calculate the length of the lookbe-
- hind. The \X and \R escapes, which can match different numbers of
- bytes, are also not permitted.
+ hind. The \X and \R escapes, which can match different numbers of data
+ units, are also not permitted.
"Subroutine" calls (see below) such as (?2) or (?&X) are permitted in
lookbehinds, as long as the subpattern matches a fixed-length string.
@@ -5338,12 +5788,12 @@ COMMENTS
comment, which in this case continues to immediately after the next
newline character or character sequence in the pattern. Which charac-
ters are interpreted as newlines is controlled by the options passed to
- pcre_compile() or by a special sequence at the start of the pattern, as
- described in the section entitled "Newline conventions" above. Note
- that the end of this type of comment is a literal newline sequence in
- the pattern; escape sequences that happen to represent a newline do not
- count. For example, consider this pattern when PCRE_EXTENDED is set,
- and the default newline convention is in force:
+ a compiling function or by a special sequence at the start of the pat-
+ tern, as described in the section entitled "Newline conventions" above.
+ Note that the end of this type of comment is a literal newline sequence
+ in the pattern; escape sequences that happen to represent a newline do
+ not count. For example, consider this pattern when PCRE_EXTENDED is
+ set, and the default newline convention is in force:
abc #comment \n still comment
@@ -5636,8 +6086,8 @@ CALLOUTS
PCRE provides a similar feature, but of course it cannot obey arbitrary
Perl code. The feature is called "callout". The caller of PCRE provides
an external function by putting its entry point in the global variable
- pcre_callout. By default, this variable contains NULL, which disables
- all calling out.
+ pcre_callout (8-bit library) or pcre16_callout (16-bit library). By
+ default, this variable contains NULL, which disables all calling out.
Within a regular expression, (?C) indicates the points at which the
external function is to be called. If you want to identify different
@@ -5647,17 +6097,17 @@ CALLOUTS
(?C1)abc(?C2)def
- If the PCRE_AUTO_CALLOUT flag is passed to pcre_compile(), callouts are
- automatically installed before each item in the pattern. They are all
- numbered 255.
+ If the PCRE_AUTO_CALLOUT flag is passed to a compiling function, call-
+ outs are automatically installed before each item in the pattern. They
+ are all numbered 255.
- During matching, when PCRE reaches a callout point (and pcre_callout is
- set), the external function is called. It is provided with the number
- of the callout, the position in the pattern, and, optionally, one item
- of data originally supplied by the caller of pcre_exec(). The callout
- function may cause matching to proceed, to backtrack, or to fail alto-
- gether. A complete description of the interface to the callout function
- is given in the pcrecallout documentation.
+ During matching, when PCRE reaches a callout point, the external func-
+ tion is called. It is provided with the number of the callout, the
+ position in the pattern, and, optionally, one item of data originally
+ supplied by the caller of the matching function. The callout function
+ may cause matching to proceed, to backtrack, or to fail altogether. A
+ complete description of the interface to the callout function is given
+ in the pcrecallout documentation.
BACKTRACKING CONTROL
@@ -5670,91 +6120,92 @@ BACKTRACKING CONTROL
in this section.
Since these verbs are specifically related to backtracking, most of
- them can be used only when the pattern is to be matched using
- pcre_exec(), which uses a backtracking algorithm. With the exception of
- (*FAIL), which behaves like a failing negative assertion, they cause an
- error if encountered by pcre_dfa_exec().
+ them can be used only when the pattern is to be matched using one of
+ the traditional matching functions, which use a backtracking algorithm.
+ With the exception of (*FAIL), which behaves like a failing negative
+ assertion, they cause an error if encountered by a DFA matching func-
+ tion.
- If any of these verbs are used in an assertion or in a subpattern that
+ If any of these verbs are used in an assertion or in a subpattern that
is called as a subroutine (whether or not recursively), their effect is
confined to that subpattern; it does not extend to the surrounding pat-
tern, with one exception: the name from a *(MARK), (*PRUNE), or (*THEN)
- that is encountered in a successful positive assertion is passed back
- when a match succeeds (compare capturing parentheses in assertions).
+ that is encountered in a successful positive assertion is passed back
+ when a match succeeds (compare capturing parentheses in assertions).
Note that such subpatterns are processed as anchored at the point where
they are tested. Note also that Perl's treatment of subroutines is dif-
ferent in some cases.
- The new verbs make use of what was previously invalid syntax: an open-
+ The new verbs make use of what was previously invalid syntax: an open-
ing parenthesis followed by an asterisk. They are generally of the form
- (*VERB) or (*VERB:NAME). Some may take either form, with differing be-
- haviour, depending on whether or not an argument is present. A name is
+ (*VERB) or (*VERB:NAME). Some may take either form, with differing be-
+ haviour, depending on whether or not an argument is present. A name is
any sequence of characters that does not include a closing parenthesis.
- If the name is empty, that is, if the closing parenthesis immediately
- follows the colon, the effect is as if the colon were not there. Any
+ If the name is empty, that is, if the closing parenthesis immediately
+ follows the colon, the effect is as if the colon were not there. Any
number of these verbs may occur in a pattern.
- PCRE contains some optimizations that are used to speed up matching by
+ PCRE contains some optimizations that are used to speed up matching by
running some checks at the start of each match attempt. For example, it
- may know the minimum length of matching subject, or that a particular
- character must be present. When one of these optimizations suppresses
- the running of a match, any included backtracking verbs will not, of
+ may know the minimum length of matching subject, or that a particular
+ character must be present. When one of these optimizations suppresses
+ the running of a match, any included backtracking verbs will not, of
course, be processed. You can suppress the start-of-match optimizations
- by setting the PCRE_NO_START_OPTIMIZE option when calling pcre_com-
+ by setting the PCRE_NO_START_OPTIMIZE option when calling pcre_com-
pile() or pcre_exec(), or by starting the pattern with (*NO_START_OPT).
- Experiments with Perl suggest that it too has similar optimizations,
+ Experiments with Perl suggest that it too has similar optimizations,
sometimes leading to anomalous results.
Verbs that act immediately
- The following verbs act as soon as they are encountered. They may not
+ The following verbs act as soon as they are encountered. They may not
be followed by a name.
(*ACCEPT)
- This verb causes the match to end successfully, skipping the remainder
- of the pattern. However, when it is inside a subpattern that is called
- as a subroutine, only that subpattern is ended successfully. Matching
- then continues at the outer level. If (*ACCEPT) is inside capturing
+ This verb causes the match to end successfully, skipping the remainder
+ of the pattern. However, when it is inside a subpattern that is called
+ as a subroutine, only that subpattern is ended successfully. Matching
+ then continues at the outer level. If (*ACCEPT) is inside capturing
parentheses, the data so far is captured. For example:
A((?:A|B(*ACCEPT)|C)D)
- This matches "AB", "AAD", or "ACD"; when it matches "AB", "B" is cap-
+ This matches "AB", "AAD", or "ACD"; when it matches "AB", "B" is cap-
tured by the outer parentheses.
(*FAIL) or (*F)
- This verb causes a matching failure, forcing backtracking to occur. It
- is equivalent to (?!) but easier to read. The Perl documentation notes
- that it is probably useful only when combined with (?{}) or (??{}).
- Those are, of course, Perl features that are not present in PCRE. The
- nearest equivalent is the callout feature, as for example in this pat-
+ This verb causes a matching failure, forcing backtracking to occur. It
+ is equivalent to (?!) but easier to read. The Perl documentation notes
+ that it is probably useful only when combined with (?{}) or (??{}).
+ Those are, of course, Perl features that are not present in PCRE. The
+ nearest equivalent is the callout feature, as for example in this pat-
tern:
a+(?C)(*FAIL)
- A match with the string "aaaa" always fails, but the callout is taken
+ A match with the string "aaaa" always fails, but the callout is taken
before each backtrack happens (in this example, 10 times).
Recording which path was taken
- There is one verb whose main purpose is to track how a match was
- arrived at, though it also has a secondary use in conjunction with
+ There is one verb whose main purpose is to track how a match was
+ arrived at, though it also has a secondary use in conjunction with
advancing the match starting point (see (*SKIP) below).
(*MARK:NAME) or (*:NAME)
- A name is always required with this verb. There may be as many
- instances of (*MARK) as you like in a pattern, and their names do not
+ A name is always required with this verb. There may be as many
+ instances of (*MARK) as you like in a pattern, and their names do not
have to be unique.
- When a match succeeds, the name of the last-encountered (*MARK) on the
- matching path is passed back to the caller via the pcre_extra data
- structure, as described in the section on pcre_extra in the pcreapi
- documentation. Here is an example of pcretest output, where the /K mod-
- ifier requests the retrieval and outputting of (*MARK) data:
+ When a match succeeds, the name of the last-encountered (*MARK) on the
+ matching path is passed back to the caller as described in the section
+ entitled "Extra data for pcre_exec()" in the pcreapi documentation.
+ Here is an example of pcretest output, where the /K modifier requests
+ the retrieval and outputting of (*MARK) data:
re> /X(*MARK:A)Y|X(*MARK:B)Z/K
data> XY
@@ -5765,59 +6216,59 @@ BACKTRACKING CONTROL
MK: B
The (*MARK) name is tagged with "MK:" in this output, and in this exam-
- ple it indicates which of the two alternatives matched. This is a more
- efficient way of obtaining this information than putting each alterna-
+ ple it indicates which of the two alternatives matched. This is a more
+ efficient way of obtaining this information than putting each alterna-
tive in its own capturing parentheses.
If (*MARK) is encountered in a positive assertion, its name is recorded
and passed back if it is the last-encountered. This does not happen for
negative assertions.
- After a partial match or a failed match, the name of the last encoun-
+ After a partial match or a failed match, the name of the last encoun-
tered (*MARK) in the entire match process is returned. For example:
re> /X(*MARK:A)Y|X(*MARK:B)Z/K
data> XP
No match, mark = B
- Note that in this unanchored example the mark is retained from the
+ Note that in this unanchored example the mark is retained from the
match attempt that started at the letter "X". Subsequent match attempts
- starting at "P" and then with an empty string do not get as far as the
+ starting at "P" and then with an empty string do not get as far as the
(*MARK) item, but nevertheless do not reset it.
Verbs that act after backtracking
The following verbs do nothing when they are encountered. Matching con-
- tinues with what follows, but if there is no subsequent match, causing
- a backtrack to the verb, a failure is forced. That is, backtracking
- cannot pass to the left of the verb. However, when one of these verbs
- appears inside an atomic group, its effect is confined to that group,
- because once the group has been matched, there is never any backtrack-
- ing into it. In this situation, backtracking can "jump back" to the
- left of the entire atomic group. (Remember also, as stated above, that
+ tinues with what follows, but if there is no subsequent match, causing
+ a backtrack to the verb, a failure is forced. That is, backtracking
+ cannot pass to the left of the verb. However, when one of these verbs
+ appears inside an atomic group, its effect is confined to that group,
+ because once the group has been matched, there is never any backtrack-
+ ing into it. In this situation, backtracking can "jump back" to the
+ left of the entire atomic group. (Remember also, as stated above, that
this localization also applies in subroutine calls and assertions.)
- These verbs differ in exactly what kind of failure occurs when back-
+ These verbs differ in exactly what kind of failure occurs when back-
tracking reaches them.
(*COMMIT)
- This verb, which may not be followed by a name, causes the whole match
+ This verb, which may not be followed by a name, causes the whole match
to fail outright if the rest of the pattern does not match. Even if the
pattern is unanchored, no further attempts to find a match by advancing
the starting point take place. Once (*COMMIT) has been passed,
- pcre_exec() is committed to finding a match at the current starting
+ pcre_exec() is committed to finding a match at the current starting
point, or not at all. For example:
a+(*COMMIT)b
- This matches "xxaab" but not "aacaab". It can be thought of as a kind
+ This matches "xxaab" but not "aacaab". It can be thought of as a kind
of dynamic anchor, or "I've started, so I must finish." The name of the
- most recently passed (*MARK) in the path is passed back when (*COMMIT)
+ most recently passed (*MARK) in the path is passed back when (*COMMIT)
forces a match failure.
- Note that (*COMMIT) at the start of a pattern is not the same as an
- anchor, unless PCRE's start-of-match optimizations are turned off, as
+ Note that (*COMMIT) at the start of a pattern is not the same as an
+ anchor, unless PCRE's start-of-match optimizations are turned off, as
shown in this pcretest example:
re> /(*COMMIT)abc/
@@ -5826,111 +6277,111 @@ BACKTRACKING CONTROL
xyzabc\Y
No match
- PCRE knows that any match must start with "a", so the optimization
- skips along the subject to "a" before running the first match attempt,
- which succeeds. When the optimization is disabled by the \Y escape in
+ PCRE knows that any match must start with "a", so the optimization
+ skips along the subject to "a" before running the first match attempt,
+ which succeeds. When the optimization is disabled by the \Y escape in
the second subject, the match starts at "x" and so the (*COMMIT) causes
it to fail without trying any other starting points.
(*PRUNE) or (*PRUNE:NAME)
- This verb causes the match to fail at the current starting position in
- the subject if the rest of the pattern does not match. If the pattern
- is unanchored, the normal "bumpalong" advance to the next starting
- character then happens. Backtracking can occur as usual to the left of
- (*PRUNE), before it is reached, or when matching to the right of
- (*PRUNE), but if there is no match to the right, backtracking cannot
- cross (*PRUNE). In simple cases, the use of (*PRUNE) is just an alter-
- native to an atomic group or possessive quantifier, but there are some
+ This verb causes the match to fail at the current starting position in
+ the subject if the rest of the pattern does not match. If the pattern
+ is unanchored, the normal "bumpalong" advance to the next starting
+ character then happens. Backtracking can occur as usual to the left of
+ (*PRUNE), before it is reached, or when matching to the right of
+ (*PRUNE), but if there is no match to the right, backtracking cannot
+ cross (*PRUNE). In simple cases, the use of (*PRUNE) is just an alter-
+ native to an atomic group or possessive quantifier, but there are some
uses of (*PRUNE) that cannot be expressed in any other way. The behav-
- iour of (*PRUNE:NAME) is the same as (*MARK:NAME)(*PRUNE). In an
+ iour of (*PRUNE:NAME) is the same as (*MARK:NAME)(*PRUNE). In an
anchored pattern (*PRUNE) has the same effect as (*COMMIT).
(*SKIP)
- This verb, when given without a name, is like (*PRUNE), except that if
- the pattern is unanchored, the "bumpalong" advance is not to the next
+ This verb, when given without a name, is like (*PRUNE), except that if
+ the pattern is unanchored, the "bumpalong" advance is not to the next
character, but to the position in the subject where (*SKIP) was encoun-
- tered. (*SKIP) signifies that whatever text was matched leading up to
+ tered. (*SKIP) signifies that whatever text was matched leading up to
it cannot be part of a successful match. Consider:
a+(*SKIP)b
- If the subject is "aaaac...", after the first match attempt fails
- (starting at the first character in the string), the starting point
+ If the subject is "aaaac...", after the first match attempt fails
+ (starting at the first character in the string), the starting point
skips on to start the next attempt at "c". Note that a possessive quan-
- tifer does not have the same effect as this example; although it would
- suppress backtracking during the first match attempt, the second
- attempt would start at the second character instead of skipping on to
+ tifer does not have the same effect as this example; although it would
+ suppress backtracking during the first match attempt, the second
+ attempt would start at the second character instead of skipping on to
"c".
(*SKIP:NAME)
- When (*SKIP) has an associated name, its behaviour is modified. If the
+ When (*SKIP) has an associated name, its behaviour is modified. If the
following pattern fails to match, the previous path through the pattern
- is searched for the most recent (*MARK) that has the same name. If one
- is found, the "bumpalong" advance is to the subject position that cor-
- responds to that (*MARK) instead of to where (*SKIP) was encountered.
+ is searched for the most recent (*MARK) that has the same name. If one
+ is found, the "bumpalong" advance is to the subject position that cor-
+ responds to that (*MARK) instead of to where (*SKIP) was encountered.
If no (*MARK) with a matching name is found, the (*SKIP) is ignored.
(*THEN) or (*THEN:NAME)
- This verb causes a skip to the next innermost alternative if the rest
- of the pattern does not match. That is, it cancels pending backtrack-
- ing, but only within the current alternative. Its name comes from the
+ This verb causes a skip to the next innermost alternative if the rest
+ of the pattern does not match. That is, it cancels pending backtrack-
+ ing, but only within the current alternative. Its name comes from the
observation that it can be used for a pattern-based if-then-else block:
( COND1 (*THEN) FOO | COND2 (*THEN) BAR | COND3 (*THEN) BAZ ) ...
- If the COND1 pattern matches, FOO is tried (and possibly further items
- after the end of the group if FOO succeeds); on failure, the matcher
- skips to the second alternative and tries COND2, without backtracking
- into COND1. The behaviour of (*THEN:NAME) is exactly the same as
- (*MARK:NAME)(*THEN). If (*THEN) is not inside an alternation, it acts
+ If the COND1 pattern matches, FOO is tried (and possibly further items
+ after the end of the group if FOO succeeds); on failure, the matcher
+ skips to the second alternative and tries COND2, without backtracking
+ into COND1. The behaviour of (*THEN:NAME) is exactly the same as
+ (*MARK:NAME)(*THEN). If (*THEN) is not inside an alternation, it acts
like (*PRUNE).
- Note that a subpattern that does not contain a | character is just a
- part of the enclosing alternative; it is not a nested alternation with
- only one alternative. The effect of (*THEN) extends beyond such a sub-
- pattern to the enclosing alternative. Consider this pattern, where A,
+ Note that a subpattern that does not contain a | character is just a
+ part of the enclosing alternative; it is not a nested alternation with
+ only one alternative. The effect of (*THEN) extends beyond such a sub-
+ pattern to the enclosing alternative. Consider this pattern, where A,
B, etc. are complex pattern fragments that do not contain any | charac-
ters at this level:
A (B(*THEN)C) | D
- If A and B are matched, but there is a failure in C, matching does not
+ If A and B are matched, but there is a failure in C, matching does not
backtrack into A; instead it moves to the next alternative, that is, D.
- However, if the subpattern containing (*THEN) is given an alternative,
+ However, if the subpattern containing (*THEN) is given an alternative,
it behaves differently:
A (B(*THEN)C | (*FAIL)) | D
- The effect of (*THEN) is now confined to the inner subpattern. After a
+ The effect of (*THEN) is now confined to the inner subpattern. After a
failure in C, matching moves to (*FAIL), which causes the whole subpat-
- tern to fail because there are no more alternatives to try. In this
+ tern to fail because there are no more alternatives to try. In this
case, matching does now backtrack into A.
Note also that a conditional subpattern is not considered as having two
- alternatives, because only one is ever used. In other words, the |
+ alternatives, because only one is ever used. In other words, the |
character in a conditional subpattern has a different meaning. Ignoring
white space, consider:
^.*? (?(?=a) a | b(*THEN)c )
- If the subject is "ba", this pattern does not match. Because .*? is
- ungreedy, it initially matches zero characters. The condition (?=a)
- then fails, the character "b" is matched, but "c" is not. At this
- point, matching does not backtrack to .*? as might perhaps be expected
- from the presence of the | character. The conditional subpattern is
+ If the subject is "ba", this pattern does not match. Because .*? is
+ ungreedy, it initially matches zero characters. The condition (?=a)
+ then fails, the character "b" is matched, but "c" is not. At this
+ point, matching does not backtrack to .*? as might perhaps be expected
+ from the presence of the | character. The conditional subpattern is
part of the single alternative that comprises the whole pattern, and so
- the match fails. (If there was a backtrack into .*?, allowing it to
+ the match fails. (If there was a backtrack into .*?, allowing it to
match "b", the match would succeed.)
- The verbs just described provide four different "strengths" of control
+ The verbs just described provide four different "strengths" of control
when subsequent matching fails. (*THEN) is the weakest, carrying on the
- match at the next alternative. (*PRUNE) comes next, failing the match
- at the current starting position, but allowing an advance to the next
- character (for an unanchored pattern). (*SKIP) is similar, except that
+ match at the next alternative. (*PRUNE) comes next, failing the match
+ at the current starting position, but allowing an advance to the next
+ character (for an unanchored pattern). (*SKIP) is similar, except that
the advance may be more than one character. (*COMMIT) is the strongest,
causing the entire match to fail.
@@ -5940,15 +6391,16 @@ BACKTRACKING CONTROL
(A(*COMMIT)B(*THEN)C|D)
- Once A has matched, PCRE is committed to this match, at the current
- starting position. If subsequently B matches, but C does not, the nor-
+ Once A has matched, PCRE is committed to this match, at the current
+ starting position. If subsequently B matches, but C does not, the nor-
mal (*THEN) action of trying the next alternative (that is, D) does not
happen because (*COMMIT) overrides.
SEE ALSO
- pcreapi(3), pcrecallout(3), pcrematching(3), pcresyntax(3), pcre(3).
+ pcreapi(3), pcrecallout(3), pcrematching(3), pcresyntax(3), pcre(3),
+ pcre16(3).
AUTHOR
@@ -5960,11 +6412,11 @@ AUTHOR
REVISION
- Last updated: 29 November 2011
- Copyright (c) 1997-2011 University of Cambridge.
+ Last updated: 09 January 2012
+ Copyright (c) 1997-2012 University of Cambridge.
------------------------------------------------------------------------------
-
-
+
+
PCRESYNTAX(3) PCRESYNTAX(3)
@@ -5976,7 +6428,7 @@ PCRE REGULAR EXPRESSION SYNTAX SUMMARY
The full syntax and semantics of the regular expressions that are sup-
ported by PCRE are described in the pcrepattern documentation. This
- document contains just a quick-reference summary of the syntax.
+ document contains a quick-reference summary of the syntax.
QUOTING
@@ -6003,7 +6455,7 @@ CHARACTER TYPES
. any character except newline;
in dotall mode, any character whatsoever
- \C one byte, even in UTF-8 mode (best avoided)
+ \C one data unit, even in UTF mode (best avoided)
\d a decimal digit
\D a character that is not a decimal digit
\h a horizontal whitespace character
@@ -6021,7 +6473,7 @@ CHARACTER TYPES
\X an extended Unicode sequence
In PCRE, by default, \d, \D, \s, \S, \w, and \W recognize only ASCII
- characters, even in UTF-8 mode. However, this can be changed by setting
+ characters, even in a UTF mode. However, this can be changed by setting
the PCRE_UCP option.
@@ -6208,7 +6660,8 @@ OPTION SETTING
one of the newline-setting options with similar syntax:
(*NO_START_OPT) no start-match optimization (PCRE_NO_START_OPTIMIZE)
- (*UTF8) set UTF-8 mode (PCRE_UTF8)
+ (*UTF8) set UTF-8 mode: 8-bit library (PCRE_UTF8)
+ (*UTF16) set UTF-16 mode: 16-bit library (PCRE_UTF16)
(*UCP) set PCRE_UCP (use Unicode properties for \d etc)
@@ -6277,6 +6730,7 @@ BACKTRACKING CONTROL
(*ACCEPT) force successful match
(*FAIL) force backtrack; synonym (*F)
+ (*MARK:NAME) set name to be passed back; synonym (*:NAME)
The following act only when a subsequent match failure causes a back-
track to reach them. They all force a match failure, but they differ in
@@ -6285,14 +6739,18 @@ BACKTRACKING CONTROL
(*COMMIT) overall failure, no advance of starting point
(*PRUNE) advance to next starting character
- (*SKIP) advance start to current matching position
+ (*PRUNE:NAME) equivalent to (*MARK:NAME)(*PRUNE)
+ (*SKIP) advance to current matching position
+ (*SKIP:NAME) advance to position corresponding to an earlier
+ (*MARK:NAME); if not found, the (*SKIP) is ignored
(*THEN) local failure, backtrack to next alternation
+ (*THEN:NAME) equivalent to (*MARK:NAME)(*THEN)
NEWLINE CONVENTIONS
These are recognized only at the very start of the pattern or after a
- (*BSR_...) or (*UTF8) or (*UCP) option.
+ (*BSR_...), (*UTF8), (*UTF16) or (*UCP) option.
(*CR) carriage return only
(*LF) linefeed only
@@ -6304,7 +6762,7 @@ NEWLINE CONVENTIONS
WHAT \R MATCHES
These are recognized only at the very start of the pattern or after a
- (*...) option that sets the newline convention or UTF-8 or UCP mode.
+ (*...) option that sets the newline convention or a UTF or UCP mode.
(*BSR_ANYCRLF) CR, LF, or CRLF
(*BSR_UNICODE) any Unicode newline sequence
@@ -6330,11 +6788,11 @@ AUTHOR
REVISION
- Last updated: 21 November 2010
- Copyright (c) 1997-2010 University of Cambridge.
+ Last updated: 10 January 2012
+ Copyright (c) 1997-2012 University of Cambridge.
------------------------------------------------------------------------------
-
-
+
+
PCREUNICODE(3) PCREUNICODE(3)
@@ -6342,52 +6800,72 @@ NAME
PCRE - Perl-compatible regular expressions
-UTF-8 AND UNICODE PROPERTY SUPPORT
+UTF-8, UTF-16, AND UNICODE PROPERTY SUPPORT
- In order process UTF-8 strings, you must build PCRE to include UTF-8
- support in the code, and, in addition, you must call pcre_compile()
- with the PCRE_UTF8 option flag, or the pattern must start with the
- sequence (*UTF8). When either of these is the case, both the pattern
- and any subject strings that are matched against it are treated as
- UTF-8 strings instead of strings of 1-byte characters. PCRE does not
- support any other formats (in particular, it does not support UTF-16).
+ From Release 8.30, in addition to its previous UTF-8 support, PCRE also
+ supports UTF-16 by means of a separate 16-bit library. This can be
+ built as well as, or instead of, the 8-bit library.
- If you compile PCRE with UTF-8 support, but do not use it at run time,
+
+UTF-8 SUPPORT
+
+ In order process UTF-8 strings, you must build PCRE's 8-bit library
+ with UTF support, and, in addition, you must call pcre_compile() with
+ the PCRE_UTF8 option flag, or the pattern must start with the sequence
+ (*UTF8). When either of these is the case, both the pattern and any
+ subject strings that are matched against it are treated as UTF-8
+ strings instead of strings of 1-byte characters.
+
+
+UTF-16 SUPPORT
+
+ In order process UTF-16 strings, you must build PCRE's 16-bit library
+ with UTF support, and, in addition, you must call pcre16_compile() with
+ the PCRE_UTF16 option flag, or the pattern must start with the sequence
+ (*UTF16). When either of these is the case, both the pattern and any
+ subject strings that are matched against it are treated as UTF-16
+ strings instead of strings of 16-bit characters.
+
+
+UTF SUPPORT OVERHEAD
+
+ If you compile PCRE with UTF support, but do not use it at run time,
the library will be a bit bigger, but the additional run time overhead
- is limited to testing the PCRE_UTF8 flag occasionally, so should not be
- very big.
+ is limited to testing the PCRE_UTF8/16 flag occasionally, so should not
+ be very big.
+
+
+UNICODE PROPERTY SUPPORT
If PCRE is built with Unicode character property support (which implies
- UTF-8 support), the escape sequences \p{..}, \P{..}, and \X are sup-
- ported. The available properties that can be tested are limited to the
- general category properties such as Lu for an upper case letter or Nd
- for a decimal number, the Unicode script names such as Arabic or Han,
- and the derived properties Any and L&. A full list is given in the
- pcrepattern documentation. Only the short names for properties are sup-
- ported. For example, \p{L} matches a letter. Its Perl synonym, \p{Let-
- ter}, is not supported. Furthermore, in Perl, many properties may
- optionally be prefixed by "Is", for compatibility with Perl 5.6. PCRE
- does not support this.
+ UTF support), the escape sequences \p{..}, \P{..}, and \X can be used.
+ The available properties that can be tested are limited to the general
+ category properties such as Lu for an upper case letter or Nd for a
+ decimal number, the Unicode script names such as Arabic or Han, and the
+ derived properties Any and L&. A full list is given in the pcrepattern
+ documentation. Only the short names for properties are supported. For
+ example, \p{L} matches a letter. Its Perl synonym, \p{Letter}, is not
+ supported. Furthermore, in Perl, many properties may optionally be
+ prefixed by "Is", for compatibility with Perl 5.6. PCRE does not sup-
+ port this.
Validity of UTF-8 strings
- When you set the PCRE_UTF8 flag, the strings passed as patterns and
- subjects are (by default) checked for validity on entry to the relevant
- functions. From release 7.3 of PCRE, the check is according the rules
- of RFC 3629, which are themselves derived from the Unicode specifica-
- tion. Earlier releases of PCRE followed the rules of RFC 2279, which
- allows the full range of 31-bit values (0 to 0x7FFFFFFF). The current
- check allows only values in the range U+0 to U+10FFFF, excluding U+D800
- to U+DFFF.
-
- The excluded code points are the "Low Surrogate Area" of Unicode, of
- which the Unicode Standard says this: "The Low Surrogate Area does not
- contain any character assignments, consequently no character code
- charts or namelists are provided for this area. Surrogates are reserved
- for use with UTF-16 and then must be used in pairs." The code points
- that are encoded by UTF-16 pairs are available as independent code
- points in the UTF-8 encoding. (In other words, the whole surrogate
- thing is a fudge for UTF-16 which unfortunately messes up UTF-8.)
+ When you set the PCRE_UTF8 flag, the byte strings passed as patterns
+ and subjects are (by default) checked for validity on entry to the rel-
+ evant functions. From release 7.3 of PCRE, the check is according the
+ rules of RFC 3629, which are themselves derived from the Unicode speci-
+ fication. Earlier releases of PCRE followed the rules of RFC 2279,
+ which allows the full range of 31-bit values (0 to 0x7FFFFFFF). The
+ current check allows only values in the range U+0 to U+10FFFF, exclud-
+ ing U+D800 to U+DFFF.
+
+ The excluded code points are the "Surrogate Area" of Unicode. They are
+ reserved for use by UTF-16, where they are used in pairs to encode
+ codepoints with values greater than 0xFFFF. The code points that are
+ encoded by UTF-16 pairs are available independently in the UTF-8 encod-
+ ing. (In other words, the whole surrogate thing is a fudge for UTF-16
+ which unfortunately messes up UTF-8.)
If an invalid UTF-8 string is passed to PCRE, an error return is given.
At compile time, the only additional information is the offset to the
@@ -6420,42 +6898,66 @@ UTF-8 AND UNICODE PROPERTY SUPPORT
this situation, you will have to apply your own validity check, and
avoid the use of JIT optimization.
- General comments about UTF-8 mode
-
- 1. An unbraced hexadecimal escape sequence (such as \xb3) matches a
- two-byte UTF-8 character if the value is greater than 127.
-
- 2. Octal numbers up to \777 are recognized, and match two-byte UTF-8
- characters for values greater than \177.
-
- 3. Repeat quantifiers apply to complete UTF-8 characters, not to indi-
- vidual bytes, for example: \x{100}{3}.
-
- 4. The dot metacharacter matches one UTF-8 character instead of a sin-
- gle byte.
-
- 5. The escape sequence \C can be used to match a single byte in UTF-8
- mode, but its use can lead to some strange effects because it breaks up
- multibyte characters (see the description of \C in the pcrepattern doc-
- umentation). The use of \C is not supported in the alternative matching
- function pcre_dfa_exec(), nor is it supported in UTF-8 mode by the JIT
- optimization of pcre_exec(). If JIT optimization is requested for a
- UTF-8 pattern that contains \C, it will not succeed, and so the match-
- ing will be carried out by the normal interpretive function.
+ Validity of UTF-16 strings
+
+ When you set the PCRE_UTF16 flag, the strings of 16-bit data units that
+ are passed as patterns and subjects are (by default) checked for valid-
+ ity on entry to the relevant functions. Values other than those in the
+ surrogate range U+D800 to U+DFFF are independent code points. Values in
+ the surrogate range must be used in pairs in the correct manner.
+
+ If an invalid UTF-16 string is passed to PCRE, an error return is
+ given. At compile time, the only additional information is the offset
+ to the first data unit of the failing character. The runtime functions
+ pcre16_exec() and pcre16_dfa_exec() also pass back this information, as
+ well as a more detailed reason code if the caller has provided memory
+ in which to do this.
+
+ In some situations, you may already know that your strings are valid,
+ and therefore want to skip these checks in order to improve perfor-
+ mance. If you set the PCRE_NO_UTF16_CHECK flag at compile time or at
+ run time, PCRE assumes that the pattern or subject it is given (respec-
+ tively) contains only valid UTF-16 sequences. In this case, it does not
+ diagnose an invalid UTF-16 string.
+
+ General comments about UTF modes
+
+ 1. Codepoints less than 256 can be specified by either braced or
+ unbraced hexadecimal escape sequences (for example, \x{b3} or \xb3).
+ Larger values have to use braced sequences.
+
+ 2. Octal numbers up to \777 are recognized, and in UTF-8 mode, they
+ match two-byte characters for values greater than \177.
+
+ 3. Repeat quantifiers apply to complete UTF characters, not to individ-
+ ual data units, for example: \x{100}{3}.
+
+ 4. The dot metacharacter matches one UTF character instead of a single
+ data unit.
+
+ 5. The escape sequence \C can be used to match a single byte in UTF-8
+ mode, or a single 16-bit data unit in UTF-16 mode, but its use can lead
+ to some strange effects because it breaks up multi-unit characters (see
+ the description of \C in the pcrepattern documentation). The use of \C
+ is not supported in the alternative matching function
+ pcre[16]_dfa_exec(), nor is it supported in UTF mode by the JIT opti-
+ mization of pcre[16]_exec(). If JIT optimization is requested for a UTF
+ pattern that contains \C, it will not succeed, and so the matching will
+ be carried out by the normal interpretive function.
6. The character escapes \b, \B, \d, \D, \s, \S, \w, and \W correctly
test characters of any code value, but, by default, the characters that
PCRE recognizes as digits, spaces, or word characters remain the same
- set as before, all with values less than 256. This remains true even
- when PCRE is built to include Unicode property support, because to do
- otherwise would slow down PCRE in many common cases. Note in particular
- that this applies to \b and \B, because they are defined in terms of \w
- and \W. If you really want to test for a wider sense of, say, "digit",
- you can use explicit Unicode property tests such as \p{Nd}. Alterna-
- tively, if you set the PCRE_UCP option, the way that the character
- escapes work is changed so that Unicode properties are used to deter-
- mine which characters match. There are more details in the section on
- generic character types in the pcrepattern documentation.
+ set as in non-UTF mode, all with values less than 256. This remains
+ true even when PCRE is built to include Unicode property support,
+ because to do otherwise would slow down PCRE in many common cases. Note
+ in particular that this applies to \b and \B, because they are defined
+ in terms of \w and \W. If you really want to test for a wider sense of,
+ say, "digit", you can use explicit Unicode property tests such as
+ \p{Nd}. Alternatively, if you set the PCRE_UCP option, the way that the
+ character escapes work is changed so that Unicode properties are used
+ to determine which characters match. There are more details in the sec-
+ tion on generic character types in the pcrepattern documentation.
7. Similarly, characters that match the POSIX named character classes
are all low-valued characters, unless the PCRE_UCP option is set.
@@ -6484,11 +6986,11 @@ AUTHOR
REVISION
- Last updated: 19 October 2011
- Copyright (c) 1997-2011 University of Cambridge.
+ Last updated: 13 January 2012
+ Copyright (c) 1997-2012 University of Cambridge.
------------------------------------------------------------------------------
-
-
+
+
PCREJIT(3) PCREJIT(3)
@@ -6502,15 +7004,24 @@ PCRE JUST-IN-TIME COMPILER SUPPORT
speed up pattern matching. However, it comes at the cost of extra pro-
cessing before the match is performed. Therefore, it is of most benefit
when the same pattern is going to be matched many times. This does not
- necessarily mean many calls of pcre_exec(); if the pattern is not
- anchored, matching attempts may take place many times at various posi-
- tions in the subject, even for a single call to pcre_exec(). If the
+ necessarily mean many calls of a matching function; if the pattern is
+ not anchored, matching attempts may take place many times at various
+ positions in the subject, even for a single call. Therefore, if the
subject string is very long, it may still pay to use JIT for one-off
matches.
- JIT support applies only to the traditional matching function,
- pcre_exec(). It does not apply when pcre_dfa_exec() is being used. The
- code for this support was written by Zoltan Herczeg.
+ JIT support applies only to the traditional Perl-compatible matching
+ function. It does not apply when the DFA matching function is being
+ used. The code for this support was written by Zoltan Herczeg.
+
+
+8-BIT and 16-BIT SUPPORT
+
+ JIT support is available for both the 8-bit and 16-bit PCRE libraries.
+ To keep this documentation simple, only the 8-bit interface is
+ described in what follows. If you are using the 16-bit library, substi-
+ tute the 16-bit functions and 16-bit structures (for example,
+ pcre16_jit_stack instead of pcre_jit_stack).
AVAILABILITY OF JIT SUPPORT
@@ -6523,7 +7034,7 @@ AVAILABILITY OF JIT SUPPORT
ARM v5, v7, and Thumb2
Intel x86 32-bit and 64-bit
MIPS 32-bit
- Power PC 32-bit and 64-bit (experimental)
+ Power PC 32-bit and 64-bit
The Power PC support is designated as experimental because it has not
been fully tested. If --enable-jit is set on an unsupported platform,
@@ -6831,11 +7342,11 @@ AUTHOR
REVISION
- Last updated: 26 November 2011
- Copyright (c) 1997-2011 University of Cambridge.
+ Last updated: 08 January 2012
+ Copyright (c) 1997-2012 University of Cambridge.
------------------------------------------------------------------------------
-
-
+
+
PCREPARTIAL(3) PCREPARTIAL(3)
@@ -6845,11 +7356,11 @@ NAME
PARTIAL MATCHING IN PCRE
- In normal use of PCRE, if the subject string that is passed to
- pcre_exec() or pcre_dfa_exec() matches as far as it goes, but is too
- short to match the entire pattern, PCRE_ERROR_NOMATCH is returned.
- There are circumstances where it might be helpful to distinguish this
- case from other cases in which there is no match.
+ In normal use of PCRE, if the subject string that is passed to a match-
+ ing function matches as far as it goes, but is too short to match the
+ entire pattern, PCRE_ERROR_NOMATCH is returned. There are circumstances
+ where it might be helpful to distinguish this case from other cases in
+ which there is no match.
Consider, for example, an application where a human is required to type
in data for a field with specific formatting requirements. An example
@@ -6867,43 +7378,43 @@ PARTIAL MATCHING IN PCRE
available at once.
PCRE supports partial matching by means of the PCRE_PARTIAL_SOFT and
- PCRE_PARTIAL_HARD options, which can be set when calling pcre_exec() or
- pcre_dfa_exec(). For backwards compatibility, PCRE_PARTIAL is a synonym
- for PCRE_PARTIAL_SOFT. The essential difference between the two options
- is whether or not a partial match is preferred to an alternative com-
- plete match, though the details differ between the two matching func-
- tions. If both options are set, PCRE_PARTIAL_HARD takes precedence.
-
- Setting a partial matching option for pcre_exec() disables the use of
- any just-in-time code that was set up by calling pcre_study() with the
- PCRE_STUDY_JIT_COMPILE option. It also disables two of PCRE's standard
- optimizations. PCRE remembers the last literal byte in a pattern, and
- abandons matching immediately if such a byte is not present in the sub-
- ject string. This optimization cannot be used for a subject string that
- might match only partially. If the pattern was studied, PCRE knows the
- minimum length of a matching string, and does not bother to run the
- matching function on shorter strings. This optimization is also dis-
+ PCRE_PARTIAL_HARD options, which can be set when calling any of the
+ matching functions. For backwards compatibility, PCRE_PARTIAL is a syn-
+ onym for PCRE_PARTIAL_SOFT. The essential difference between the two
+ options is whether or not a partial match is preferred to an alterna-
+ tive complete match, though the details differ between the two types of
+ matching function. If both options are set, PCRE_PARTIAL_HARD takes
+ precedence.
+
+ Setting a partial matching option disables the use of any just-in-time
+ code that was set up by studying the compiled pattern with the
+ PCRE_STUDY_JIT_COMPILE option. It also disables two of PCRE's standard
+ optimizations. PCRE remembers the last literal data unit in a pattern,
+ and abandons matching immediately if it is not present in the subject
+ string. This optimization cannot be used for a subject string that
+ might match only partially. If the pattern was studied, PCRE knows the
+ minimum length of a matching string, and does not bother to run the
+ matching function on shorter strings. This optimization is also dis-
abled for partial matching.
-PARTIAL MATCHING USING pcre_exec()
+PARTIAL MATCHING USING pcre_exec() OR pcre16_exec()
- A partial match occurs during a call to pcre_exec() when the end of the
- subject string is reached successfully, but matching cannot continue
- because more characters are needed. However, at least one character in
- the subject must have been inspected. This character need not form part
- of the final matched string; lookbehind assertions and the \K escape
- sequence provide ways of inspecting characters before the start of a
- matched substring. The requirement for inspecting at least one charac-
- ter exists because an empty string can always be matched; without such
- a restriction there would always be a partial match of an empty string
- at the end of the subject.
+ A partial match occurs during a call to pcre_exec() or pcre16_exec()
+ when the end of the subject string is reached successfully, but match-
+ ing cannot continue because more characters are needed. However, at
+ least one character in the subject must have been inspected. This char-
+ acter need not form part of the final matched string; lookbehind asser-
+ tions and the \K escape sequence provide ways of inspecting characters
+ before the start of a matched substring. The requirement for inspecting
+ at least one character exists because an empty string can always be
+ matched; without such a restriction there would always be a partial
+ match of an empty string at the end of the subject.
- If there are at least two slots in the offsets vector when pcre_exec()
- returns with a partial match, the first slot is set to the offset of
- the earliest character that was inspected when the partial match was
- found. For convenience, the second offset points to the end of the sub-
- ject so that a substring can easily be identified.
+ If there are at least two slots in the offsets vector when a partial
+ match is returned, the first slot is set to the offset of the earliest
+ character that was inspected. For convenience, the second offset points
+ to the end of the subject so that a substring can easily be identified.
For the majority of patterns, the first offset identifies the start of
the partially matched string. However, for patterns that contain look-
@@ -6920,13 +7431,13 @@ PARTIAL MATCHING USING pcre_exec()
What happens when a partial match is identified depends on which of the
two partial matching options are set.
- PCRE_PARTIAL_SOFT with pcre_exec()
+ PCRE_PARTIAL_SOFT WITH pcre_exec() OR pcre16_exec()
- If PCRE_PARTIAL_SOFT is set when pcre_exec() identifies a partial
- match, the partial match is remembered, but matching continues as nor-
- mal, and other alternatives in the pattern are tried. If no complete
- match can be found, pcre_exec() returns PCRE_ERROR_PARTIAL instead of
- PCRE_ERROR_NOMATCH.
+ If PCRE_PARTIAL_SOFT is set when pcre_exec() or pcre16_exec() identi-
+ fies a partial match, the partial match is remembered, but matching
+ continues as normal, and other alternatives in the pattern are tried.
+ If no complete match can be found, PCRE_ERROR_PARTIAL is returned
+ instead of PCRE_ERROR_NOMATCH.
This option is "soft" because it prefers a complete match over a par-
tial match. All the various matching items in a pattern behave as if
@@ -6946,99 +7457,97 @@ PARTIAL MATCHING USING pcre_exec()
(In this example, there are two partial matches, because "dog" on its
own partially matches the second alternative.)
- PCRE_PARTIAL_HARD with pcre_exec()
+ PCRE_PARTIAL_HARD WITH pcre_exec() OR pcre16_exec()
- If PCRE_PARTIAL_HARD is set for pcre_exec(), it returns PCRE_ERROR_PAR-
- TIAL as soon as a partial match is found, without continuing to search
- for possible complete matches. This option is "hard" because it prefers
- an earlier partial match over a later complete match. For this reason,
- the assumption is made that the end of the supplied subject string may
- not be the true end of the available data, and so, if \z, \Z, \b, \B,
- or $ are encountered at the end of the subject, the result is
- PCRE_ERROR_PARTIAL.
+ If PCRE_PARTIAL_HARD is set for pcre_exec() or pcre16_exec(),
+ PCRE_ERROR_PARTIAL is returned as soon as a partial match is found,
+ without continuing to search for possible complete matches. This option
+ is "hard" because it prefers an earlier partial match over a later com-
+ plete match. For this reason, the assumption is made that the end of
+ the supplied subject string may not be the true end of the available
+ data, and so, if \z, \Z, \b, \B, or $ are encountered at the end of the
+ subject, the result is PCRE_ERROR_PARTIAL.
- Setting PCRE_PARTIAL_HARD also affects the way pcre_exec() checks UTF-8
- subject strings for validity. Normally, an invalid UTF-8 sequence
- causes the error PCRE_ERROR_BADUTF8. However, in the special case of a
- truncated UTF-8 character at the end of the subject, PCRE_ERROR_SHORT-
- UTF8 is returned when PCRE_PARTIAL_HARD is set.
+ Setting PCRE_PARTIAL_HARD also affects the way UTF-8 and UTF-16 subject
+ strings are checked for validity. Normally, an invalid sequence causes
+ the error PCRE_ERROR_BADUTF8 or PCRE_ERROR_BADUTF16. However, in the
+ special case of a truncated character at the end of the subject,
+ PCRE_ERROR_SHORTUTF8 or PCRE_ERROR_SHORTUTF16 is returned when
+ PCRE_PARTIAL_HARD is set.
Comparing hard and soft partial matching
- The difference between the two partial matching options can be illus-
+ The difference between the two partial matching options can be illus-
trated by a pattern such as:
/dog(sbody)?/
- This matches either "dog" or "dogsbody", greedily (that is, it prefers
- the longer string if possible). If it is matched against the string
- "dog" with PCRE_PARTIAL_SOFT, it yields a complete match for "dog".
+ This matches either "dog" or "dogsbody", greedily (that is, it prefers
+ the longer string if possible). If it is matched against the string
+ "dog" with PCRE_PARTIAL_SOFT, it yields a complete match for "dog".
However, if PCRE_PARTIAL_HARD is set, the result is PCRE_ERROR_PARTIAL.
- On the other hand, if the pattern is made ungreedy the result is dif-
+ On the other hand, if the pattern is made ungreedy the result is dif-
ferent:
/dog(sbody)??/
- In this case the result is always a complete match because pcre_exec()
- finds that first, and it never continues after finding a match. It
- might be easier to follow this explanation by thinking of the two pat-
- terns like this:
+ In this case the result is always a complete match because that is
+ found first, and matching never continues after finding a complete
+ match. It might be easier to follow this explanation by thinking of the
+ two patterns like this:
/dog(sbody)?/ is the same as /dogsbody|dog/
/dog(sbody)??/ is the same as /dog|dogsbody/
- The second pattern will never match "dogsbody" when pcre_exec() is
- used, because it will always find the shorter match first.
+ The second pattern will never match "dogsbody", because it will always
+ find the shorter match first.
-PARTIAL MATCHING USING pcre_dfa_exec()
+PARTIAL MATCHING USING pcre_dfa_exec() OR pcre16_dfa_exec()
- The pcre_dfa_exec() function moves along the subject string character
- by character, without backtracking, searching for all possible matches
- simultaneously. If the end of the subject is reached before the end of
- the pattern, there is the possibility of a partial match, again pro-
- vided that at least one character has been inspected.
+ The DFA functions move along the subject string character by character,
+ without backtracking, searching for all possible matches simultane-
+ ously. If the end of the subject is reached before the end of the pat-
+ tern, there is the possibility of a partial match, again provided that
+ at least one character has been inspected.
- When PCRE_PARTIAL_SOFT is set, PCRE_ERROR_PARTIAL is returned only if
- there have been no complete matches. Otherwise, the complete matches
- are returned. However, if PCRE_PARTIAL_HARD is set, a partial match
- takes precedence over any complete matches. The portion of the string
- that was inspected when the longest partial match was found is set as
+ When PCRE_PARTIAL_SOFT is set, PCRE_ERROR_PARTIAL is returned only if
+ there have been no complete matches. Otherwise, the complete matches
+ are returned. However, if PCRE_PARTIAL_HARD is set, a partial match
+ takes precedence over any complete matches. The portion of the string
+ that was inspected when the longest partial match was found is set as
the first matching string, provided there are at least two slots in the
offsets vector.
- Because pcre_dfa_exec() always searches for all possible matches, and
- there is no difference between greedy and ungreedy repetition, its be-
- haviour is different from pcre_exec when PCRE_PARTIAL_HARD is set. Con-
- sider the string "dog" matched against the ungreedy pattern shown
- above:
+ Because the DFA functions always search for all possible matches, and
+ there is no difference between greedy and ungreedy repetition, their
+ behaviour is different from the standard functions when PCRE_PAR-
+ TIAL_HARD is set. Consider the string "dog" matched against the
+ ungreedy pattern shown above:
/dog(sbody)??/
- Whereas pcre_exec() stops as soon as it finds the complete match for
- "dog", pcre_dfa_exec() also finds the partial match for "dogsbody", and
- so returns that when PCRE_PARTIAL_HARD is set.
+ Whereas the standard functions stop as soon as they find the complete
+ match for "dog", the DFA functions also find the partial match for
+ "dogsbody", and so return that when PCRE_PARTIAL_HARD is set.
PARTIAL MATCHING AND WORD BOUNDARIES
- If a pattern ends with one of sequences \b or \B, which test for word
- boundaries, partial matching with PCRE_PARTIAL_SOFT can give counter-
+ If a pattern ends with one of sequences \b or \B, which test for word
+ boundaries, partial matching with PCRE_PARTIAL_SOFT can give counter-
intuitive results. Consider this pattern:
/\bcat\b/
This matches "cat", provided there is a word boundary at either end. If
the subject string is "the cat", the comparison of the final "t" with a
- following character cannot take place, so a partial match is found.
- However, pcre_exec() carries on with normal matching, which matches \b
- at the end of the subject when the last character is a letter, thus
- finding a complete match. The result, therefore, is not PCRE_ERROR_PAR-
- TIAL. The same thing happens with pcre_dfa_exec(), because it also
- finds the complete match.
-
- Using PCRE_PARTIAL_HARD in this case does yield PCRE_ERROR_PARTIAL,
- because then the partial match takes precedence.
+ following character cannot take place, so a partial match is found.
+ However, normal matching carries on, and \b matches at the end of the
+ subject when the last character is a letter, so a complete match is
+ found. The result, therefore, is not PCRE_ERROR_PARTIAL. Using
+ PCRE_PARTIAL_HARD in this case does yield PCRE_ERROR_PARTIAL, because
+ then the partial match takes precedence.
FORMERLY RESTRICTED PATTERNS
@@ -7047,8 +7556,8 @@ FORMERLY RESTRICTED PATTERNS
optimizations were implemented in the pcre_exec() function, the
PCRE_PARTIAL option (predecessor of PCRE_PARTIAL_SOFT) could not be
used with all patterns. From release 8.00 onwards, the restrictions no
- longer apply, and partial matching with pcre_exec() can be requested
- for any pattern.
+ longer apply, and partial matching with can be requested for any pat-
+ tern.
Items that were formerly restricted were repeated single characters and
repeated metasequences. If PCRE_PARTIAL was set for a pattern that did
@@ -7080,22 +7589,22 @@ EXAMPLE OF PARTIAL MATCHING USING PCRETEST
The first data string is matched completely, so pcretest shows the
matched substrings. The remaining four strings do not match the com-
plete pattern, but the first two are partial matches. Similar output is
- obtained when pcre_dfa_exec() is used.
+ obtained if DFA matching is used.
If the escape sequence \P is present more than once in a pcretest data
line, the PCRE_PARTIAL_HARD option is set for the match.
-MULTI-SEGMENT MATCHING WITH pcre_dfa_exec()
+MULTI-SEGMENT MATCHING WITH pcre_dfa_exec() OR pcre16_dfa_exec()
- When a partial match has been found using pcre_dfa_exec(), it is possi-
- ble to continue the match by providing additional subject data and
- calling pcre_dfa_exec() again with the same compiled regular expres-
+ When a partial match has been found using a DFA matching function, it
+ is possible to continue the match by providing additional subject data
+ and calling the function again with the same compiled regular expres-
sion, this time setting the PCRE_DFA_RESTART option. You must pass the
same working space as before, because this is where details of the pre-
vious partial match are stored. Here is an example using pcretest,
using the \R escape sequence to set the PCRE_DFA_RESTART option (\D
- specifies the use of pcre_dfa_exec()):
+ specifies the use of the DFA matching function):
re> /^\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d$/
data> 23ja\P\D
@@ -7112,37 +7621,39 @@ MULTI-SEGMENT MATCHING WITH pcre_dfa_exec()
You can set the PCRE_PARTIAL_SOFT or PCRE_PARTIAL_HARD options with
PCRE_DFA_RESTART to continue partial matching over multiple segments.
- This facility can be used to pass very long subject strings to
- pcre_dfa_exec().
+ This facility can be used to pass very long subject strings to the DFA
+ matching functions.
+
+MULTI-SEGMENT MATCHING WITH pcre_exec() OR pcre16_exec()
-MULTI-SEGMENT MATCHING WITH pcre_exec()
+ From release 8.00, the standard matching functions can also be used to
+ do multi-segment matching. Unlike the DFA functions, it is not possible
+ to restart the previous match with a new segment of data. Instead, new
+ data must be added to the previous subject string, and the entire match
+ re-run, starting from the point where the partial match occurred. Ear-
+ lier data can be discarded.
- From release 8.00, pcre_exec() can also be used to do multi-segment
- matching. Unlike pcre_dfa_exec(), it is not possible to restart the
- previous match with a new segment of data. Instead, new data must be
- added to the previous subject string, and the entire match re-run,
- starting from the point where the partial match occurred. Earlier data
- can be discarded. It is best to use PCRE_PARTIAL_HARD in this situa-
- tion, because it does not treat the end of a segment as the end of the
- subject when matching \z, \Z, \b, \B, and $. Consider an unanchored
- pattern that matches dates:
+ It is best to use PCRE_PARTIAL_HARD in this situation, because it does
+ not treat the end of a segment as the end of the subject when matching
+ \z, \Z, \b, \B, and $. Consider an unanchored pattern that matches
+ dates:
re> /\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d/
data> The date is 23ja\P\P
Partial match: 23ja
At this stage, an application could discard the text preceding "23ja",
- add on text from the next segment, and call pcre_exec() again. Unlike
- pcre_dfa_exec(), the entire matching string must always be available,
- and the complete matching process occurs for each call, so more memory
- and more processing time is needed.
+ add on text from the next segment, and call the matching function
+ again. Unlike the DFA matching functions the entire matching string
+ must always be available, and the complete matching process occurs for
+ each call, so more memory and more processing time is needed.
Note: If the pattern contains lookbehind assertions, or \K, or starts
- with \b or \B, the string that is returned for a partial match will
- include characters that precede the partially matched string itself,
- because these must be retained when adding on more characters for a
- subsequent matching attempt.
+ with \b or \B, the string that is returned for a partial match includes
+ characters that precede the partially matched string itself, because
+ these must be retained when adding on more characters for a subsequent
+ matching attempt.
ISSUES WITH MULTI-SEGMENT MATCHING
@@ -7186,17 +7697,18 @@ ISSUES WITH MULTI-SEGMENT MATCHING
0: dogsbody
1: dog
- The first data line passes the string "dogsb" to pcre_exec(), setting
- the PCRE_PARTIAL_SOFT option. Although the string is a partial match
- for "dogsbody", the result is not PCRE_ERROR_PARTIAL, because the
- shorter string "dog" is a complete match. Similarly, when the subject
- is presented to pcre_dfa_exec() in several parts ("do" and "gsb" being
- the first two) the match stops when "dog" has been found, and it is not
- possible to continue. On the other hand, if "dogsbody" is presented as
- a single string, pcre_dfa_exec() finds both matches.
-
- Because of these problems, it is best to use PCRE_PARTIAL_HARD when
- matching multi-segment data. The example above then behaves differ-
+ The first data line passes the string "dogsb" to a standard matching
+ function, setting the PCRE_PARTIAL_SOFT option. Although the string is
+ a partial match for "dogsbody", the result is not PCRE_ERROR_PARTIAL,
+ because the shorter string "dog" is a complete match. Similarly, when
+ the subject is presented to a DFA matching function in several parts
+ ("do" and "gsb" being the first two) the match stops when "dog" has
+ been found, and it is not possible to continue. On the other hand, if
+ "dogsbody" is presented as a single string, a DFA matching function
+ finds both matches.
+
+ Because of these problems, it is best to use PCRE_PARTIAL_HARD when
+ matching multi-segment data. The example above then behaves differ-
ently:
re> /dog(sbody)?/
@@ -7208,9 +7720,8 @@ ISSUES WITH MULTI-SEGMENT MATCHING
Partial match: gsb
4. Patterns that contain alternatives at the top level which do not all
- start with the same pattern item may not work as expected when
- PCRE_DFA_RESTART is used with pcre_dfa_exec(). For example, consider
- this pattern:
+ start with the same pattern item may not work as expected when
+ PCRE_DFA_RESTART is used. For example, consider this pattern:
1234|3789
@@ -7227,8 +7738,8 @@ ISSUES WITH MULTI-SEGMENT MATCHING
1234|ABCD
where no string can be a partial match for both alternatives. This is
- not a problem if pcre_exec() is used, because the entire match has to
- be rerun each time:
+ not a problem if a standard matching function is used, because the
+ entire match has to be rerun each time:
re> /1234|3789/
data> ABC123\P\P
@@ -7237,11 +7748,11 @@ ISSUES WITH MULTI-SEGMENT MATCHING
0: 3789
Of course, instead of using PCRE_DFA_RESTART, the same technique of re-
- running the entire match can also be used with pcre_dfa_exec(). Another
- possibility is to work with two buffers. If a partial match at offset n
- in the first buffer is followed by "no match" when PCRE_DFA_RESTART is
- used on the second buffer, you can then try a new match starting at
- offset n+1 in the first buffer.
+ running the entire match can also be used with the DFA matching func-
+ tions. Another possibility is to work with two buffers. If a partial
+ match at offset n in the first buffer is followed by "no match" when
+ PCRE_DFA_RESTART is used on the second buffer, you can then try a new
+ match starting at offset n+1 in the first buffer.
AUTHOR
@@ -7253,11 +7764,11 @@ AUTHOR
REVISION
- Last updated: 26 August 2011
- Copyright (c) 1997-2011 University of Cambridge.
+ Last updated: 08 January 2012
+ Copyright (c) 1997-2012 University of Cambridge.
------------------------------------------------------------------------------
-
-
+
+
PCREPRECOMPILE(3) PCREPRECOMPILE(3)
@@ -7273,28 +7784,31 @@ SAVING AND RE-USING PRECOMPILED PCRE PATTERNS
run. If you are not using any private character tables (see the
pcre_maketables() documentation), this is relatively straightforward.
If you are using private tables, it is a little bit more complicated.
- However, if you are using the just-in-time optimization feature of
- pcre_study(), it is not possible to save and reload the JIT data.
+ However, if you are using the just-in-time optimization feature, it is
+ not possible to save and reload the JIT data.
If you save compiled patterns to a file, you can copy them to a differ-
- ent host and run them there. This works even if the new host has the
- opposite endianness to the one on which the patterns were compiled.
- There may be a small performance penalty, but it should be insignifi-
- cant. However, compiling regular expressions with one version of PCRE
- for use with a different version is not guaranteed to work and may
- cause crashes, and saving and restoring a compiled pattern loses any
- JIT optimization data.
+ ent host and run them there. If the two hosts have different endianness
+ (byte order), you should run the pcre[16]_pattern_to_host_byte_order()
+ function on the new host before trying to match the pattern. The match-
+ ing functions return PCRE_ERROR_BADENDIANNESS if they detect a pattern
+ with the wrong endianness.
+
+ Compiling regular expressions with one version of PCRE for use with a
+ different version is not guaranteed to work and may cause crashes, and
+ saving and restoring a compiled pattern loses any JIT optimization
+ data.
SAVING A COMPILED PATTERN
- The value returned by pcre_compile() points to a single block of memory
- that holds the compiled pattern and associated data. You can find the
- length of this block in bytes by calling pcre_fullinfo() with an argu-
- ment of PCRE_INFO_SIZE. You can then save the data in any appropriate
- manner. Here is sample code that compiles a pattern and writes it to a
- file. It assumes that the variable fd refers to a file that is open for
- output:
+ The value returned by pcre[16]_compile() points to a single block of
+ memory that holds the compiled pattern and associated data. You can
+ find the length of this block in bytes by calling pcre[16]_fullinfo()
+ with an argument of PCRE_INFO_SIZE. You can then save the data in any
+ appropriate manner. Here is sample code for the 8-bit library that com-
+ piles a pattern and writes it to a file. It assumes that the variable
+ fd refers to a file that is open for output:
int erroroffset, rc, size;
char *error;
@@ -7307,65 +7821,66 @@ SAVING A COMPILED PATTERN
rc = fwrite(re, 1, size, fd);
if (rc != size) { ... handle errors ... }
- In this example, the bytes that comprise the compiled pattern are
- copied exactly. Note that this is binary data that may contain any of
- the 256 possible byte values. On systems that make a distinction
+ In this example, the bytes that comprise the compiled pattern are
+ copied exactly. Note that this is binary data that may contain any of
+ the 256 possible byte values. On systems that make a distinction
between binary and non-binary data, be sure that the file is opened for
binary output.
- If you want to write more than one pattern to a file, you will have to
- devise a way of separating them. For binary data, preceding each pat-
- tern with its length is probably the most straightforward approach.
- Another possibility is to write out the data in hexadecimal instead of
+ If you want to write more than one pattern to a file, you will have to
+ devise a way of separating them. For binary data, preceding each pat-
+ tern with its length is probably the most straightforward approach.
+ Another possibility is to write out the data in hexadecimal instead of
binary, one pattern to a line.
- Saving compiled patterns in a file is only one possible way of storing
- them for later use. They could equally well be saved in a database, or
- in the memory of some daemon process that passes them via sockets to
+ Saving compiled patterns in a file is only one possible way of storing
+ them for later use. They could equally well be saved in a database, or
+ in the memory of some daemon process that passes them via sockets to
the processes that want them.
If the pattern has been studied, it is also possible to save the normal
study data in a similar way to the compiled pattern itself. However, if
the PCRE_STUDY_JIT_COMPILE was used, the just-in-time data that is cre-
- ated cannot be saved because it is too dependent on the current envi-
- ronment. When studying generates additional information, pcre_study()
- returns a pointer to a pcre_extra data block. Its format is defined in
- the section on matching a pattern in the pcreapi documentation. The
- study_data field points to the binary study data, and this is what you
- must save (not the pcre_extra block itself). The length of the study
- data can be obtained by calling pcre_fullinfo() with an argument of
- PCRE_INFO_STUDYSIZE. Remember to check that pcre_study() did return a
- non-NULL value before trying to save the study data.
+ ated cannot be saved because it is too dependent on the current envi-
+ ronment. When studying generates additional information,
+ pcre[16]_study() returns a pointer to a pcre[16]_extra data block. Its
+ format is defined in the section on matching a pattern in the pcreapi
+ documentation. The study_data field points to the binary study data,
+ and this is what you must save (not the pcre[16]_extra block itself).
+ The length of the study data can be obtained by calling
+ pcre[16]_fullinfo() with an argument of PCRE_INFO_STUDYSIZE. Remember
+ to check that pcre[16]_study() did return a non-NULL value before try-
+ ing to save the study data.
RE-USING A PRECOMPILED PATTERN
Re-using a precompiled pattern is straightforward. Having reloaded it
- into main memory, you pass its pointer to pcre_exec() or
- pcre_dfa_exec() in the usual way. This should work even on another
- host, and even if that host has the opposite endianness to the one
- where the pattern was compiled.
-
- However, if you passed a pointer to custom character tables when the
- pattern was compiled (the tableptr argument of pcre_compile()), you
- must now pass a similar pointer to pcre_exec() or pcre_dfa_exec(),
- because the value saved with the compiled pattern will obviously be
- nonsense. A field in a pcre_extra() block is used to pass this data, as
- described in the section on matching a pattern in the pcreapi documen-
- tation.
-
- If you did not provide custom character tables when the pattern was
- compiled, the pointer in the compiled pattern is NULL, which causes
- pcre_exec() to use PCRE's internal tables. Thus, you do not need to
- take any special action at run time in this case.
-
- If you saved study data with the compiled pattern, you need to create
- your own pcre_extra data block and set the study_data field to point to
- the reloaded study data. You must also set the PCRE_EXTRA_STUDY_DATA
- bit in the flags field to indicate that study data is present. Then
- pass the pcre_extra block to pcre_exec() or pcre_dfa_exec() in the
- usual way. If the pattern was studied for just-in-time optimization,
- that data cannot be saved, and so is lost by a save/restore cycle.
+ into main memory, called pcre[16]_pattern_to_host_byte_order() if nec-
+ essary, you pass its pointer to pcre[16]_exec() or pcre[16]_dfa_exec()
+ in the usual way.
+
+ However, if you passed a pointer to custom character tables when the
+ pattern was compiled (the tableptr argument of pcre[16]_compile()), you
+ must now pass a similar pointer to pcre[16]_exec() or
+ pcre[16]_dfa_exec(), because the value saved with the compiled pattern
+ will obviously be nonsense. A field in a pcre[16]_extra() block is used
+ to pass this data, as described in the section on matching a pattern in
+ the pcreapi documentation.
+
+ If you did not provide custom character tables when the pattern was
+ compiled, the pointer in the compiled pattern is NULL, which causes the
+ matching functions to use PCRE's internal tables. Thus, you do not need
+ to take any special action at run time in this case.
+
+ If you saved study data with the compiled pattern, you need to create
+ your own pcre[16]_extra data block and set the study_data field to
+ point to the reloaded study data. You must also set the
+ PCRE_EXTRA_STUDY_DATA bit in the flags field to indicate that study
+ data is present. Then pass the pcre[16]_extra block to the matching
+ function in the usual way. If the pattern was studied for just-in-time
+ optimization, that data cannot be saved, and so is lost by a
+ save/restore cycle.
COMPATIBILITY WITH DIFFERENT PCRE RELEASES
@@ -7384,11 +7899,11 @@ AUTHOR
REVISION
- Last updated: 26 August 2011
- Copyright (c) 1997-2011 University of Cambridge.
+ Last updated: 10 January 2012
+ Copyright (c) 1997-2012 University of Cambridge.
------------------------------------------------------------------------------
-
-
+
+
PCREPERFORM(3) PCREPERFORM(3)
@@ -7405,12 +7920,12 @@ PCRE PERFORMANCE
COMPILED PATTERN MEMORY USAGE
- Patterns are compiled by PCRE into a reasonably efficient byte code, so
- that most simple patterns do not use much memory. However, there is one
- case where the memory usage of a compiled pattern can be unexpectedly
- large. If a parenthesized subpattern has a quantifier with a minimum
- greater than 1 and/or a limited maximum, the whole subpattern is
- repeated in the compiled code. For example, the pattern
+ Patterns are compiled by PCRE into a reasonably efficient interpretive
+ code, so that most simple patterns do not use much memory. However,
+ there is one case where the memory usage of a compiled pattern can be
+ unexpectedly large. If a parenthesized subpattern has a quantifier with
+ a minimum greater than 1 and/or a limited maximum, the whole subpattern
+ is repeated in the compiled code. For example, the pattern
(abc|def){2,4}
@@ -7428,64 +7943,66 @@ COMPILED PATTERN MEMORY USAGE
((ab){1,1000}c){1,3}
- uses 51K bytes when compiled. When PCRE is compiled with its default
- internal pointer size of two bytes, the size limit on a compiled pat-
- tern is 64K, and this is reached with the above pattern if the outer
- repetition is increased from 3 to 4. PCRE can be compiled to use larger
- internal pointers and thus handle larger compiled patterns, but it is
- better to try to rewrite your pattern to use less memory if you can.
+ uses 51K bytes when compiled using the 8-bit library. When PCRE is com-
+ piled with its default internal pointer size of two bytes, the size
+ limit on a compiled pattern is 64K data units, and this is reached with
+ the above pattern if the outer repetition is increased from 3 to 4.
+ PCRE can be compiled to use larger internal pointers and thus handle
+ larger compiled patterns, but it is better to try to rewrite your pat-
+ tern to use less memory if you can.
- One way of reducing the memory usage for such patterns is to make use
+ One way of reducing the memory usage for such patterns is to make use
of PCRE's "subroutine" facility. Re-writing the above pattern as
((ab)(?2){0,999}c)(?1){0,2}
reduces the memory requirements to 18K, and indeed it remains under 20K
- even with the outer repetition increased to 100. However, this pattern
- is not exactly equivalent, because the "subroutine" calls are treated
- as atomic groups into which there can be no backtracking if there is a
- subsequent matching failure. Therefore, PCRE cannot do this kind of
- rewriting automatically. Furthermore, there is a noticeable loss of
- speed when executing the modified pattern. Nevertheless, if the atomic
- grouping is not a problem and the loss of speed is acceptable, this
- kind of rewriting will allow you to process patterns that PCRE cannot
+ even with the outer repetition increased to 100. However, this pattern
+ is not exactly equivalent, because the "subroutine" calls are treated
+ as atomic groups into which there can be no backtracking if there is a
+ subsequent matching failure. Therefore, PCRE cannot do this kind of
+ rewriting automatically. Furthermore, there is a noticeable loss of
+ speed when executing the modified pattern. Nevertheless, if the atomic
+ grouping is not a problem and the loss of speed is acceptable, this
+ kind of rewriting will allow you to process patterns that PCRE cannot
otherwise handle.
STACK USAGE AT RUN TIME
- When pcre_exec() is used for matching, certain kinds of pattern can
- cause it to use large amounts of the process stack. In some environ-
- ments the default process stack is quite small, and if it runs out the
- result is often SIGSEGV. This issue is probably the most frequently
- raised problem with PCRE. Rewriting your pattern can often help. The
- pcrestack documentation discusses this issue in detail.
+ When pcre_exec() or pcre16_exec() is used for matching, certain kinds
+ of pattern can cause it to use large amounts of the process stack. In
+ some environments the default process stack is quite small, and if it
+ runs out the result is often SIGSEGV. This issue is probably the most
+ frequently raised problem with PCRE. Rewriting your pattern can often
+ help. The pcrestack documentation discusses this issue in detail.
PROCESSING TIME
- Certain items in regular expression patterns are processed more effi-
+ Certain items in regular expression patterns are processed more effi-
ciently than others. It is more efficient to use a character class like
- [aeiou] than a set of single-character alternatives such as
- (a|e|i|o|u). In general, the simplest construction that provides the
+ [aeiou] than a set of single-character alternatives such as
+ (a|e|i|o|u). In general, the simplest construction that provides the
required behaviour is usually the most efficient. Jeffrey Friedl's book
- contains a lot of useful general discussion about optimizing regular
- expressions for efficient performance. This document contains a few
+ contains a lot of useful general discussion about optimizing regular
+ expressions for efficient performance. This document contains a few
observations about PCRE.
- Using Unicode character properties (the \p, \P, and \X escapes) is
- slow, because PCRE has to scan a structure that contains data for over
- fifteen thousand characters whenever it needs a character's property.
- If you can find an alternative pattern that does not use character
+ Using Unicode character properties (the \p, \P, and \X escapes) is
+ slow, because PCRE has to scan a structure that contains data for over
+ fifteen thousand characters whenever it needs a character's property.
+ If you can find an alternative pattern that does not use character
properties, it will probably be faster.
- By default, the escape sequences \b, \d, \s, and \w, and the POSIX
- character classes such as [:alpha:] do not use Unicode properties,
+ By default, the escape sequences \b, \d, \s, and \w, and the POSIX
+ character classes such as [:alpha:] do not use Unicode properties,
partly for backwards compatibility, and partly for performance reasons.
- However, you can set PCRE_UCP if you want Unicode character properties
- to be used. This can double the matching time for items such as \d,
- when matched with pcre_exec(); the performance loss is less with
- pcre_dfa_exec(), and in both cases there is not much difference for \b.
+ However, you can set PCRE_UCP if you want Unicode character properties
+ to be used. This can double the matching time for items such as \d,
+ when matched with a traditional matching function; the performance loss
+ is less with a DFA matching function, and in both cases there is not
+ much difference for \b.
When a pattern begins with .* not in parentheses, or in parentheses
that are not the subject of a backreference, and the PCRE_DOTALL option
@@ -7552,11 +8069,11 @@ AUTHOR
REVISION
- Last updated: 16 May 2010
- Copyright (c) 1997-2010 University of Cambridge.
+ Last updated: 09 January 2012
+ Copyright (c) 1997-2012 University of Cambridge.
------------------------------------------------------------------------------
-
-
+
+
PCREPOSIX(3) PCREPOSIX(3)
@@ -7582,51 +8099,52 @@ SYNOPSIS OF POSIX API
DESCRIPTION
- This set of functions provides a POSIX-style API to the PCRE regular
- expression package. See the pcreapi documentation for a description of
- PCRE's native API, which contains much additional functionality.
+ This set of functions provides a POSIX-style API for the PCRE regular
+ expression 8-bit library. See the pcreapi documentation for a descrip-
+ tion of PCRE's native API, which contains much additional functional-
+ ity. There is no POSIX-style wrapper for PCRE's 16-bit library.
The functions described here are just wrapper functions that ultimately
call the PCRE native API. Their prototypes are defined in the
- pcreposix.h header file, and on Unix systems the library itself is
- called pcreposix.a, so can be accessed by adding -lpcreposix to the
- command for linking an application that uses them. Because the POSIX
+ pcreposix.h header file, and on Unix systems the library itself is
+ called pcreposix.a, so can be accessed by adding -lpcreposix to the
+ command for linking an application that uses them. Because the POSIX
functions call the native ones, it is also necessary to add -lpcre.
- I have implemented only those POSIX option bits that can be reasonably
- mapped to PCRE native options. In addition, the option REG_EXTENDED is
- defined with the value zero. This has no effect, but since programs
- that are written to the POSIX interface often use it, this makes it
- easier to slot in PCRE as a replacement library. Other POSIX options
+ I have implemented only those POSIX option bits that can be reasonably
+ mapped to PCRE native options. In addition, the option REG_EXTENDED is
+ defined with the value zero. This has no effect, but since programs
+ that are written to the POSIX interface often use it, this makes it
+ easier to slot in PCRE as a replacement library. Other POSIX options
are not even defined.
- There are also some other options that are not defined by POSIX. These
+ There are also some other options that are not defined by POSIX. These
have been added at the request of users who want to make use of certain
PCRE-specific features via the POSIX calling interface.
- When PCRE is called via these functions, it is only the API that is
- POSIX-like in style. The syntax and semantics of the regular expres-
- sions themselves are still those of Perl, subject to the setting of
- various PCRE options, as described below. "POSIX-like in style" means
- that the API approximates to the POSIX definition; it is not fully
- POSIX-compatible, and in multi-byte encoding domains it is probably
+ When PCRE is called via these functions, it is only the API that is
+ POSIX-like in style. The syntax and semantics of the regular expres-
+ sions themselves are still those of Perl, subject to the setting of
+ various PCRE options, as described below. "POSIX-like in style" means
+ that the API approximates to the POSIX definition; it is not fully
+ POSIX-compatible, and in multi-byte encoding domains it is probably
even less compatible.
- The header for these functions is supplied as pcreposix.h to avoid any
- potential clash with other POSIX libraries. It can, of course, be
+ The header for these functions is supplied as pcreposix.h to avoid any
+ potential clash with other POSIX libraries. It can, of course, be
renamed or aliased as regex.h, which is the "correct" name. It provides
- two structure types, regex_t for compiled internal forms, and reg-
- match_t for returning captured substrings. It also defines some con-
- stants whose names start with "REG_"; these are used for setting
+ two structure types, regex_t for compiled internal forms, and reg-
+ match_t for returning captured substrings. It also defines some con-
+ stants whose names start with "REG_"; these are used for setting
options and identifying error codes.
COMPILING A PATTERN
- The function regcomp() is called to compile a pattern into an internal
- form. The pattern is a C string terminated by a binary zero, and is
- passed in the argument pattern. The preg argument is a pointer to a
- regex_t structure that is used as a base for storing information about
+ The function regcomp() is called to compile a pattern into an internal
+ form. The pattern is a C string terminated by a binary zero, and is
+ passed in the argument pattern. The preg argument is a pointer to a
+ regex_t structure that is used as a base for storing information about
the compiled regular expression.
The argument cflags is either zero, or contains one or more of the bits
@@ -7640,58 +8158,58 @@ COMPILING A PATTERN
REG_ICASE
- The PCRE_CASELESS option is set when the regular expression is passed
+ The PCRE_CASELESS option is set when the regular expression is passed
for compilation to the native function.
REG_NEWLINE
- The PCRE_MULTILINE option is set when the regular expression is passed
- for compilation to the native function. Note that this does not mimic
- the defined POSIX behaviour for REG_NEWLINE (see the following sec-
+ The PCRE_MULTILINE option is set when the regular expression is passed
+ for compilation to the native function. Note that this does not mimic
+ the defined POSIX behaviour for REG_NEWLINE (see the following sec-
tion).
REG_NOSUB
- The PCRE_NO_AUTO_CAPTURE option is set when the regular expression is
+ The PCRE_NO_AUTO_CAPTURE option is set when the regular expression is
passed for compilation to the native function. In addition, when a pat-
- tern that is compiled with this flag is passed to regexec() for match-
- ing, the nmatch and pmatch arguments are ignored, and no captured
+ tern that is compiled with this flag is passed to regexec() for match-
+ ing, the nmatch and pmatch arguments are ignored, and no captured
strings are returned.
REG_UCP
- The PCRE_UCP option is set when the regular expression is passed for
- compilation to the native function. This causes PCRE to use Unicode
- properties when matchine \d, \w, etc., instead of just recognizing
+ The PCRE_UCP option is set when the regular expression is passed for
+ compilation to the native function. This causes PCRE to use Unicode
+ properties when matchine \d, \w, etc., instead of just recognizing
ASCII values. Note that REG_UTF8 is not part of the POSIX standard.
REG_UNGREEDY
- The PCRE_UNGREEDY option is set when the regular expression is passed
- for compilation to the native function. Note that REG_UNGREEDY is not
+ The PCRE_UNGREEDY option is set when the regular expression is passed
+ for compilation to the native function. Note that REG_UNGREEDY is not
part of the POSIX standard.
REG_UTF8
- The PCRE_UTF8 option is set when the regular expression is passed for
- compilation to the native function. This causes the pattern itself and
- all data strings used for matching it to be treated as UTF-8 strings.
+ The PCRE_UTF8 option is set when the regular expression is passed for
+ compilation to the native function. This causes the pattern itself and
+ all data strings used for matching it to be treated as UTF-8 strings.
Note that REG_UTF8 is not part of the POSIX standard.
- In the absence of these flags, no options are passed to the native
- function. This means the the regex is compiled with PCRE default
- semantics. In particular, the way it handles newline characters in the
- subject string is the Perl way, not the POSIX way. Note that setting
- PCRE_MULTILINE has only some of the effects specified for REG_NEWLINE.
- It does not affect the way newlines are matched by . (they are not) or
+ In the absence of these flags, no options are passed to the native
+ function. This means the the regex is compiled with PCRE default
+ semantics. In particular, the way it handles newline characters in the
+ subject string is the Perl way, not the POSIX way. Note that setting
+ PCRE_MULTILINE has only some of the effects specified for REG_NEWLINE.
+ It does not affect the way newlines are matched by . (they are not) or
by a negative class such as [^a] (they are).
- The yield of regcomp() is zero on success, and non-zero otherwise. The
+ The yield of regcomp() is zero on success, and non-zero otherwise. The
preg structure is filled in on success, and one member of the structure
- is public: re_nsub contains the number of capturing subpatterns in the
+ is public: re_nsub contains the number of capturing subpatterns in the
regular expression. Various error codes are defined in the header file.
- NOTE: If the yield of regcomp() is non-zero, you must not attempt to
+ NOTE: If the yield of regcomp() is non-zero, you must not attempt to
use the contents of the preg structure. If, for example, you pass it to
regexec(), the result is undefined and your program is likely to crash.
@@ -7699,9 +8217,9 @@ COMPILING A PATTERN
MATCHING NEWLINE CHARACTERS
This area is not simple, because POSIX and Perl take different views of
- things. It is not possible to get PCRE to obey POSIX semantics, but
- then PCRE was never intended to be a POSIX engine. The following table
- lists the different possibilities for matching newline characters in
+ things. It is not possible to get PCRE to obey POSIX semantics, but
+ then PCRE was never intended to be a POSIX engine. The following table
+ lists the different possibilities for matching newline characters in
PCRE:
Default Change with
@@ -7723,19 +8241,19 @@ MATCHING NEWLINE CHARACTERS
^ matches \n in middle no REG_NEWLINE
PCRE's behaviour is the same as Perl's, except that there is no equiva-
- lent for PCRE_DOLLAR_ENDONLY in Perl. In both PCRE and Perl, there is
+ lent for PCRE_DOLLAR_ENDONLY in Perl. In both PCRE and Perl, there is
no way to stop newline from matching [^a].
- The default POSIX newline handling can be obtained by setting
- PCRE_DOTALL and PCRE_DOLLAR_ENDONLY, but there is no way to make PCRE
+ The default POSIX newline handling can be obtained by setting
+ PCRE_DOTALL and PCRE_DOLLAR_ENDONLY, but there is no way to make PCRE
behave exactly as for the REG_NEWLINE action.
MATCHING A PATTERN
- The function regexec() is called to match a compiled pattern preg
- against a given string, which is by default terminated by a zero byte
- (but see REG_STARTEND below), subject to the options in eflags. These
+ The function regexec() is called to match a compiled pattern preg
+ against a given string, which is by default terminated by a zero byte
+ (but see REG_STARTEND below), subject to the options in eflags. These
can be:
REG_NOTBOL
@@ -7757,17 +8275,17 @@ MATCHING A PATTERN
REG_STARTEND
- The string is considered to start at string + pmatch[0].rm_so and to
- have a terminating NUL located at string + pmatch[0].rm_eo (there need
- not actually be a NUL at that location), regardless of the value of
- nmatch. This is a BSD extension, compatible with but not specified by
- IEEE Standard 1003.2 (POSIX.2), and should be used with caution in
+ The string is considered to start at string + pmatch[0].rm_so and to
+ have a terminating NUL located at string + pmatch[0].rm_eo (there need
+ not actually be a NUL at that location), regardless of the value of
+ nmatch. This is a BSD extension, compatible with but not specified by
+ IEEE Standard 1003.2 (POSIX.2), and should be used with caution in
software intended to be portable to other systems. Note that a non-zero
rm_so does not imply REG_NOTBOL; REG_STARTEND affects only the location
of the string, not how it is matched.
- If the pattern was compiled with the REG_NOSUB flag, no data about any
- matched strings is returned. The nmatch and pmatch arguments of
+ If the pattern was compiled with the REG_NOSUB flag, no data about any
+ matched strings is returned. The nmatch and pmatch arguments of
regexec() are ignored.
If the value of nmatch is zero, or if the value pmatch is NULL, no data
@@ -7775,34 +8293,34 @@ MATCHING A PATTERN
Otherwise,the portion of the string that was matched, and also any cap-
tured substrings, are returned via the pmatch argument, which points to
- an array of nmatch structures of type regmatch_t, containing the mem-
- bers rm_so and rm_eo. These contain the offset to the first character
- of each substring and the offset to the first character after the end
- of each substring, respectively. The 0th element of the vector relates
- to the entire portion of string that was matched; subsequent elements
- relate to the capturing subpatterns of the regular expression. Unused
+ an array of nmatch structures of type regmatch_t, containing the mem-
+ bers rm_so and rm_eo. These contain the offset to the first character
+ of each substring and the offset to the first character after the end
+ of each substring, respectively. The 0th element of the vector relates
+ to the entire portion of string that was matched; subsequent elements
+ relate to the capturing subpatterns of the regular expression. Unused
entries in the array have both structure members set to -1.
- A successful match yields a zero return; various error codes are
- defined in the header file, of which REG_NOMATCH is the "expected"
+ A successful match yields a zero return; various error codes are
+ defined in the header file, of which REG_NOMATCH is the "expected"
failure code.
ERROR MESSAGES
The regerror() function maps a non-zero errorcode from either regcomp()
- or regexec() to a printable message. If preg is not NULL, the error
+ or regexec() to a printable message. If preg is not NULL, the error
should have arisen from the use of that structure. A message terminated
- by a binary zero is placed in errbuf. The length of the message,
- including the zero, is limited to errbuf_size. The yield of the func-
+ by a binary zero is placed in errbuf. The length of the message,
+ including the zero, is limited to errbuf_size. The yield of the func-
tion is the size of buffer needed to hold the whole message.
MEMORY USAGE
- Compiling a regular expression causes memory to be allocated and asso-
- ciated with the preg structure. The function regfree() frees all such
- memory, after which preg may no longer be used as a compiled expres-
+ Compiling a regular expression causes memory to be allocated and asso-
+ ciated with the preg structure. The function regfree() frees all such
+ memory, after which preg may no longer be used as a compiled expres-
sion.
@@ -7815,11 +8333,11 @@ AUTHOR
REVISION
- Last updated: 16 May 2010
- Copyright (c) 1997-2010 University of Cambridge.
+ Last updated: 09 January 2012
+ Copyright (c) 1997-2012 University of Cambridge.
------------------------------------------------------------------------------
-
-
+
+
PCRECPP(3) PCRECPP(3)
@@ -7837,13 +8355,14 @@ DESCRIPTION
The C++ wrapper for PCRE was provided by Google Inc. Some additional
functionality was added by Giuseppe Maxia. This brief man page was con-
structed from the notes in the pcrecpp.h file, which should be con-
- sulted for further details.
+ sulted for further details. Note that the C++ wrapper supports only the
+ original 8-bit PCRE library. There is no 16-bit support at present.
MATCHING INTERFACE
- The "FullMatch" operation checks that supplied text matches a supplied
- pattern exactly. If pointer arguments are supplied, it copies matched
+ The "FullMatch" operation checks that supplied text matches a supplied
+ pattern exactly. If pointer arguments are supplied, it copies matched
sub-strings that match sub-patterns into them.
Example: successful match
@@ -7857,10 +8376,10 @@ MATCHING INTERFACE
Example: creating a temporary RE object:
pcrecpp::RE("h.*o").FullMatch("hello");
- You can pass in a "const char*" or a "string" for "text". The examples
- below tend to use a const char*. You can, as in the different examples
- above, store the RE object explicitly in a variable or use a temporary
- RE object. The examples below use one mode or the other arbitrarily.
+ You can pass in a "const char*" or a "string" for "text". The examples
+ below tend to use a const char*. You can, as in the different examples
+ above, store the RE object explicitly in a variable or use a temporary
+ RE object. The examples below use one mode or the other arbitrarily.
Either could correctly be used for any of these examples.
You must supply extra pointer arguments to extract matched subpieces.
@@ -7886,7 +8405,7 @@ MATCHING INTERFACE
Example: fails because string cannot be stored in integer
!pcrecpp::RE("(.*)").FullMatch("ruby", &i);
- The provided pointer arguments can be pointers to any scalar numeric
+ The provided pointer arguments can be pointers to any scalar numeric
type, or one of:
string (matched piece is copied to string)
@@ -7894,7 +8413,7 @@ MATCHING INTERFACE
T (where "bool T::ParseFrom(const char*, int)" exists)
NULL (the corresponding matched sub-pattern is not copied)
- The function returns true iff all of the following conditions are sat-
+ The function returns true iff all of the following conditions are sat-
isfied:
a. "text" matches "pattern" exactly;
@@ -7909,41 +8428,41 @@ MATCHING INTERFACE
number of sub-patterns, "i"th captured sub-pattern is
ignored.
- CAVEAT: An optional sub-pattern that does not exist in the matched
- string is assigned the empty string. Therefore, the following will
+ CAVEAT: An optional sub-pattern that does not exist in the matched
+ string is assigned the empty string. Therefore, the following will
return false (because the empty string is not a valid number):
int number;
pcrecpp::RE::FullMatch("abc", "[a-z]+(\\d+)?", &number);
- The matching interface supports at most 16 arguments per call. If you
- need more, consider using the more general interface
+ The matching interface supports at most 16 arguments per call. If you
+ need more, consider using the more general interface
pcrecpp::RE::DoMatch. See pcrecpp.h for the signature for DoMatch.
- NOTE: Do not use no_arg, which is used internally to mark the end of a
- list of optional arguments, as a placeholder for missing arguments, as
+ NOTE: Do not use no_arg, which is used internally to mark the end of a
+ list of optional arguments, as a placeholder for missing arguments, as
this can lead to segfaults.
QUOTING METACHARACTERS
- You can use the "QuoteMeta" operation to insert backslashes before all
- potentially meaningful characters in a string. The returned string,
+ You can use the "QuoteMeta" operation to insert backslashes before all
+ potentially meaningful characters in a string. The returned string,
used as a regular expression, will exactly match the original string.
Example:
string quoted = RE::QuoteMeta(unquoted);
- Note that it's legal to escape a character even if it has no special
- meaning in a regular expression -- so this function does that. (This
- also makes it identical to the perl function of the same name; see
- "perldoc -f quotemeta".) For example, "1.5-2.0?" becomes
+ Note that it's legal to escape a character even if it has no special
+ meaning in a regular expression -- so this function does that. (This
+ also makes it identical to the perl function of the same name; see
+ "perldoc -f quotemeta".) For example, "1.5-2.0?" becomes
"1\.5\-2\.0\?".
PARTIAL MATCHES
- You can use the "PartialMatch" operation when you want the pattern to
+ You can use the "PartialMatch" operation when you want the pattern to
match any substring of the text.
Example: simple search for a string:
@@ -7958,13 +8477,13 @@ PARTIAL MATCHES
UTF-8 AND THE MATCHING INTERFACE
- By default, pattern and text are plain text, one byte per character.
- The UTF8 flag, passed to the constructor, causes both pattern and
+ By default, pattern and text are plain text, one byte per character.
+ The UTF8 flag, passed to the constructor, causes both pattern and
string to be treated as UTF-8 text, still a byte stream but potentially
- multiple bytes per character. In practice, the text is likelier to be
- UTF-8 than the pattern, but the match returned may depend on the UTF8
- flag, so always use it when matching UTF8 text. For example, "." will
- match one byte normally but with UTF8 set may match up to three bytes
+ multiple bytes per character. In practice, the text is likelier to be
+ UTF-8 than the pattern, but the match returned may depend on the UTF8
+ flag, so always use it when matching UTF8 text. For example, "." will
+ match one byte normally but with UTF8 set may match up to three bytes
of a multi-byte character.
Example:
@@ -7983,9 +8502,9 @@ UTF-8 AND THE MATCHING INTERFACE
PASSING MODIFIERS TO THE REGULAR EXPRESSION ENGINE
- PCRE defines some modifiers to change the behavior of the regular
- expression engine. The C++ wrapper defines an auxiliary class,
- RE_Options, as a vehicle to pass such modifiers to a RE class. Cur-
+ PCRE defines some modifiers to change the behavior of the regular
+ expression engine. The C++ wrapper defines an auxiliary class,
+ RE_Options, as a vehicle to pass such modifiers to a RE class. Cur-
rently, the following modifiers are supported:
modifier description Perl corresponding
@@ -8000,15 +8519,15 @@ PASSING MODIFIERS TO THE REGULAR EXPRESSION ENGINE
PCRE_UNGREEDY reverses * and *? N/A
PCRE_NO_AUTO_CAPTURE disables capturing parens N/A (*)
- (*) Both Perl and PCRE allow non capturing parentheses by means of the
- "?:" modifier within the pattern itself. e.g. (?:ab|cd) does not cap-
+ (*) Both Perl and PCRE allow non capturing parentheses by means of the
+ "?:" modifier within the pattern itself. e.g. (?:ab|cd) does not cap-
ture, while (ab|cd) does.
- For a full account on how each modifier works, please check the PCRE
+ For a full account on how each modifier works, please check the PCRE
API reference page.
- For each modifier, there are two member functions whose name is made
- out of the modifier in lowercase, without the "PCRE_" prefix. For
+ For each modifier, there are two member functions whose name is made
+ out of the modifier in lowercase, without the "PCRE_" prefix. For
instance, PCRE_CASELESS is handled by
bool caseless()
@@ -8018,18 +8537,18 @@ PASSING MODIFIERS TO THE REGULAR EXPRESSION ENGINE
RE_Options & set_caseless(bool)
which sets or unsets the modifier. Moreover, PCRE_EXTRA_MATCH_LIMIT can
- be accessed through the set_match_limit() and match_limit() member
- functions. Setting match_limit to a non-zero value will limit the exe-
- cution of pcre to keep it from doing bad things like blowing the stack
- or taking an eternity to return a result. A value of 5000 is good
- enough to stop stack blowup in a 2MB thread stack. Setting match_limit
- to zero disables match limiting. Alternatively, you can call
- match_limit_recursion() which uses PCRE_EXTRA_MATCH_LIMIT_RECURSION to
- limit how much PCRE recurses. match_limit() limits the number of
+ be accessed through the set_match_limit() and match_limit() member
+ functions. Setting match_limit to a non-zero value will limit the exe-
+ cution of pcre to keep it from doing bad things like blowing the stack
+ or taking an eternity to return a result. A value of 5000 is good
+ enough to stop stack blowup in a 2MB thread stack. Setting match_limit
+ to zero disables match limiting. Alternatively, you can call
+ match_limit_recursion() which uses PCRE_EXTRA_MATCH_LIMIT_RECURSION to
+ limit how much PCRE recurses. match_limit() limits the number of
matches PCRE does; match_limit_recursion() limits the depth of internal
recursion, and therefore the amount of stack that is used.
- Normally, to pass one or more modifiers to a RE class, you declare a
+ Normally, to pass one or more modifiers to a RE class, you declare a
RE_Options object, set the appropriate options, and pass this object to
a RE constructor. Example:
@@ -8038,8 +8557,8 @@ PASSING MODIFIERS TO THE REGULAR EXPRESSION ENGINE
if (RE("HELLO", opt).PartialMatch("hello world")) ...
RE_options has two constructors. The default constructor takes no argu-
- ments and creates a set of flags that are off by default. The optional
- parameter option_flags is to facilitate transfer of legacy code from C
+ ments and creates a set of flags that are off by default. The optional
+ parameter option_flags is to facilitate transfer of legacy code from C
programs. This lets you do
RE(pattern,
@@ -8053,15 +8572,15 @@ PASSING MODIFIERS TO THE REGULAR EXPRESSION ENGINE
If you are going to pass one of the most used modifiers, there are some
convenience functions that return a RE_Options class with the appropri-
- ate modifier already set: CASELESS(), UTF8(), MULTILINE(), DOTALL(),
+ ate modifier already set: CASELESS(), UTF8(), MULTILINE(), DOTALL(),
and EXTENDED().
- If you need to set several options at once, and you don't want to go
- through the pains of declaring a RE_Options object and setting several
- options, there is a parallel method that give you such ability on the
- fly. You can concatenate several set_xxxxx() member functions, since
- each of them returns a reference to its class object. For example, to
- pass PCRE_CASELESS, PCRE_EXTENDED, and PCRE_MULTILINE to a RE with one
+ If you need to set several options at once, and you don't want to go
+ through the pains of declaring a RE_Options object and setting several
+ options, there is a parallel method that give you such ability on the
+ fly. You can concatenate several set_xxxxx() member functions, since
+ each of them returns a reference to its class object. For example, to
+ pass PCRE_CASELESS, PCRE_EXTENDED, and PCRE_MULTILINE to a RE with one
statement, you may write:
RE(" ^ xyz \\s+ .* blah$",
@@ -8073,10 +8592,10 @@ PASSING MODIFIERS TO THE REGULAR EXPRESSION ENGINE
SCANNING TEXT INCREMENTALLY
- The "Consume" operation may be useful if you want to repeatedly match
+ The "Consume" operation may be useful if you want to repeatedly match
regular expressions at the front of a string and skip over them as they
- match. This requires use of the "StringPiece" type, which represents a
- sub-range of a real string. Like RE, StringPiece is defined in the
+ match. This requires use of the "StringPiece" type, which represents a
+ sub-range of a real string. Like RE, StringPiece is defined in the
pcrecpp namespace.
Example: read lines of the form "var = value" from a string.
@@ -8090,11 +8609,11 @@ SCANNING TEXT INCREMENTALLY
...;
}
- Each successful call to "Consume" will set "var/value", and also
+ Each successful call to "Consume" will set "var/value", and also
advance "input" so it points past the matched text.
- The "FindAndConsume" operation is similar to "Consume" but does not
- anchor your match at the beginning of the string. For example, you
+ The "FindAndConsume" operation is similar to "Consume" but does not
+ anchor your match at the beginning of the string. For example, you
could extract all words from a string by repeatedly calling
pcrecpp::RE("(\\w+)").FindAndConsume(&input, &word)
@@ -8103,10 +8622,10 @@ SCANNING TEXT INCREMENTALLY
PARSING HEX/OCTAL/C-RADIX NUMBERS
By default, if you pass a pointer to a numeric value, the corresponding
- text is interpreted as a base-10 number. You can instead wrap the
+ text is interpreted as a base-10 number. You can instead wrap the
pointer with a call to one of the operators Hex(), Octal(), or CRadix()
- to interpret the text in another base. The CRadix operator interprets
- C-style "0" (base-8) and "0x" (base-16) prefixes, but defaults to
+ to interpret the text in another base. The CRadix operator interprets
+ C-style "0" (base-8) and "0x" (base-16) prefixes, but defaults to
base-10.
Example:
@@ -8121,30 +8640,30 @@ PARSING HEX/OCTAL/C-RADIX NUMBERS
REPLACING PARTS OF STRINGS
- You can replace the first match of "pattern" in "str" with "rewrite".
- Within "rewrite", backslash-escaped digits (\1 to \9) can be used to
- insert text matching corresponding parenthesized group from the pat-
+ You can replace the first match of "pattern" in "str" with "rewrite".
+ Within "rewrite", backslash-escaped digits (\1 to \9) can be used to
+ insert text matching corresponding parenthesized group from the pat-
tern. \0 in "rewrite" refers to the entire matching text. For example:
string s = "yabba dabba doo";
pcrecpp::RE("b+").Replace("d", &s);
- will leave "s" containing "yada dabba doo". The result is true if the
+ will leave "s" containing "yada dabba doo". The result is true if the
pattern matches and a replacement occurs, false otherwise.
- GlobalReplace is like Replace except that it replaces all occurrences
- of the pattern in the string with the rewrite. Replacements are not
+ GlobalReplace is like Replace except that it replaces all occurrences
+ of the pattern in the string with the rewrite. Replacements are not
subject to re-matching. For example:
string s = "yabba dabba doo";
pcrecpp::RE("b+").GlobalReplace("d", &s);
- will leave "s" containing "yada dada doo". It returns the number of
+ will leave "s" containing "yada dada doo". It returns the number of
replacements made.
- Extract is like Replace, except that if the pattern matches, "rewrite"
- is copied into "out" (an additional argument) with substitutions. The
- non-matching portions of "text" are ignored. Returns true iff a match
+ Extract is like Replace, except that if the pattern matches, "rewrite"
+ is copied into "out" (an additional argument) with substitutions. The
+ non-matching portions of "text" are ignored. Returns true iff a match
occurred and the extraction happened successfully; if no match occurs,
the string is left unaffected.
@@ -8157,11 +8676,10 @@ AUTHOR
REVISION
- Last updated: 17 March 2009
- Minor typo fixed: 25 July 2011
+ Last updated: 08 January 2012
------------------------------------------------------------------------------
-
-
+
+
PCRESAMPLE(3) PCRESAMPLE(3)
@@ -8177,57 +8695,58 @@ PCRE SAMPLE PROGRAM
do not have a copy of the PCRE distribution, you can save this listing
to re-create pcredemo.c.
- The program compiles the regular expression that is its first argument,
- and matches it against the subject string in its second argument. No
- PCRE options are set, and default character tables are used. If match-
- ing succeeds, the program outputs the portion of the subject that
- matched, together with the contents of any captured substrings.
+ The demonstration program, which uses the original PCRE 8-bit library,
+ compiles the regular expression that is its first argument, and matches
+ it against the subject string in its second argument. No PCRE options
+ are set, and default character tables are used. If matching succeeds,
+ the program outputs the portion of the subject that matched, together
+ with the contents of any captured substrings.
If the -g option is given on the command line, the program then goes on
to check for further matches of the same regular expression in the same
- subject string. The logic is a little bit tricky because of the possi-
- bility of matching an empty string. Comments in the code explain what
+ subject string. The logic is a little bit tricky because of the possi-
+ bility of matching an empty string. Comments in the code explain what
is going on.
- If PCRE is installed in the standard include and library directories
+ If PCRE is installed in the standard include and library directories
for your operating system, you should be able to compile the demonstra-
tion program using this command:
gcc -o pcredemo pcredemo.c -lpcre
- If PCRE is installed elsewhere, you may need to add additional options
- to the command line. For example, on a Unix-like system that has PCRE
- installed in /usr/local, you can compile the demonstration program
+ If PCRE is installed elsewhere, you may need to add additional options
+ to the command line. For example, on a Unix-like system that has PCRE
+ installed in /usr/local, you can compile the demonstration program
using a command like this:
gcc -o pcredemo -I/usr/local/include pcredemo.c \
-L/usr/local/lib -lpcre
- In a Windows environment, if you want to statically link the program
+ In a Windows environment, if you want to statically link the program
against a non-dll pcre.a file, you must uncomment the line that defines
- PCRE_STATIC before including pcre.h, because otherwise the pcre_mal-
+ PCRE_STATIC before including pcre.h, because otherwise the pcre_mal-
loc() and pcre_free() exported functions will be declared
__declspec(dllimport), with unwanted results.
- Once you have compiled and linked the demonstration program, you can
+ Once you have compiled and linked the demonstration program, you can
run simple tests like this:
./pcredemo 'cat|dog' 'the cat sat on the mat'
./pcredemo -g 'cat|dog' 'the dog sat on the cat'
- Note that there is a much more comprehensive test program, called
- pcretest, which supports many more facilities for testing regular
- expressions and the PCRE library. The pcredemo program is provided as a
- simple coding example.
+ Note that there is a much more comprehensive test program, called
+ pcretest, which supports many more facilities for testing regular
+ expressions and both PCRE libraries. The pcredemo program is provided
+ as a simple coding example.
- If you try to run pcredemo when PCRE is not installed in the standard
- library directory, you may get an error like this on some operating
+ If you try to run pcredemo when PCRE is not installed in the standard
+ library directory, you may get an error like this on some operating
systems (e.g. Solaris):
- ld.so.1: a.out: fatal: libpcre.so.0: open failed: No such file or
+ ld.so.1: a.out: fatal: libpcre.so.0: open failed: No such file or
directory
- This is caused by the way shared library support works on those sys-
+ This is caused by the way shared library support works on those sys-
tems. You need to add
-R/usr/local/lib
@@ -8244,8 +8763,8 @@ AUTHOR
REVISION
- Last updated: 17 November 2010
- Copyright (c) 1997-2010 University of Cambridge.
+ Last updated: 10 January 2012
+ Copyright (c) 1997-2012 University of Cambridge.
------------------------------------------------------------------------------
PCRELIMITS(3) PCRELIMITS(3)
@@ -8259,13 +8778,15 @@ SIZE AND OTHER LIMITATIONS
There are some size limitations in PCRE but it is hoped that they will
never in practice be relevant.
- The maximum length of a compiled pattern is 65539 (sic) bytes if PCRE
- is compiled with the default internal linkage size of 2. If you want to
- process regular expressions that are truly enormous, you can compile
- PCRE with an internal linkage size of 3 or 4 (see the README file in
- the source distribution and the pcrebuild documentation for details).
- In these cases the limit is substantially larger. However, the speed
- of execution is slower.
+ The maximum length of a compiled pattern is approximately 64K data
+ units (bytes for the 8-bit library, 16-bit units for the 16-bit
+ library) if PCRE is compiled with the default internal linkage size of
+ 2 bytes. If you want to process regular expressions that are truly
+ enormous, you can compile PCRE with an internal linkage size of 3 or 4
+ (when building the 16-bit library, 3 is rounded up to 4). See the
+ README file in the source distribution and the pcrebuild documentation
+ for details. In these cases the limit is substantially larger. How-
+ ever, the speed of execution is slower.
All values in repeating quantifiers must be less than 65536.
@@ -8298,11 +8819,11 @@ AUTHOR
REVISION
- Last updated: 30 November 2011
- Copyright (c) 1997-2011 University of Cambridge.
+ Last updated: 08 January 2012
+ Copyright (c) 1997-2012 University of Cambridge.
------------------------------------------------------------------------------
-
-
+
+
PCRESTACK(3) PCRESTACK(3)
@@ -8312,14 +8833,14 @@ NAME
PCRE DISCUSSION OF STACK USAGE
- When you call pcre_exec(), it makes use of an internal function called
- match(). This calls itself recursively at branch points in the pattern,
- in order to remember the state of the match so that it can back up and
- try a different alternative if the first one fails. As matching pro-
- ceeds deeper and deeper into the tree of possibilities, the recursion
- depth increases. The match() function is also called in other circum-
- stances, for example, whenever a parenthesized sub-pattern is entered,
- and in certain cases of repetition.
+ When you call pcre[16]_exec(), it makes use of an internal function
+ called match(). This calls itself recursively at branch points in the
+ pattern, in order to remember the state of the match so that it can
+ back up and try a different alternative if the first one fails. As
+ matching proceeds deeper and deeper into the tree of possibilities, the
+ recursion depth increases. The match() function is also called in other
+ circumstances, for example, whenever a parenthesized sub-pattern is
+ entered, and in certain cases of repetition.
Not all calls of match() increase the recursion depth; for an item such
as a* it may be called several times at the same level, after matching
@@ -8328,28 +8849,28 @@ PCRE DISCUSSION OF STACK USAGE
result of the current call (a "tail recursion"), the function is just
restarted instead.
- The above comments apply when pcre_exec() is run in its normal inter-
- pretive manner. If the pattern was studied with the PCRE_STUDY_JIT_COM-
- PILE option, and just-in-time compiling was successful, and the options
- passed to pcre_exec() were not incompatible, the matching process uses
- the JIT-compiled code instead of the match() function. In this case,
- the memory requirements are handled entirely differently. See the pcre-
- jit documentation for details.
+ The above comments apply when pcre[16]_exec() is run in its normal
+ interpretive manner. If the pattern was studied with the
+ PCRE_STUDY_JIT_COMPILE option, and just-in-time compiling was success-
+ ful, and the options passed to pcre[16]_exec() were not incompatible,
+ the matching process uses the JIT-compiled code instead of the match()
+ function. In this case, the memory requirements are handled entirely
+ differently. See the pcrejit documentation for details.
- The pcre_dfa_exec() function operates in an entirely different way, and
- uses recursion only when there is a regular expression recursion or
+ The pcre[16]_dfa_exec() function operates in an entirely different way,
+ and uses recursion only when there is a regular expression recursion or
subroutine call in the pattern. This includes the processing of asser-
tion and "once-only" subpatterns, which are handled like subroutine
calls. Normally, these are never very deep, and the limit on the com-
- plexity of pcre_dfa_exec() is controlled by the amount of workspace it
- is given. However, it is possible to write patterns with runaway infi-
- nite recursions; such patterns will cause pcre_dfa_exec() to run out of
- stack. At present, there is no protection against this.
+ plexity of pcre[16]_dfa_exec() is controlled by the amount of workspace
+ it is given. However, it is possible to write patterns with runaway
+ infinite recursions; such patterns will cause pcre[16]_dfa_exec() to
+ run out of stack. At present, there is no protection against this.
- The comments that follow do NOT apply to pcre_dfa_exec(); they are rel-
- evant only for pcre_exec() without the JIT optimization.
+ The comments that follow do NOT apply to pcre[16]_dfa_exec(); they are
+ relevant only for pcre[16]_exec() without the JIT optimization.
- Reducing pcre_exec()'s stack usage
+ Reducing pcre[16]_exec()'s stack usage
Each time that match() is actually called recursively, it uses memory
from the process stack. For certain kinds of pattern and data, very
@@ -8382,31 +8903,31 @@ PCRE DISCUSSION OF STACK USAGE
ing long subject strings is to write repeated parenthesized subpatterns
to match more than one character whenever possible.
- Compiling PCRE to use heap instead of stack for pcre_exec()
+ Compiling PCRE to use heap instead of stack for pcre[16]_exec()
In environments where stack memory is constrained, you might want to
compile PCRE to use heap memory instead of stack for remembering back-
- up points when pcre_exec() is running. This makes it run a lot more
+ up points when pcre[16]_exec() is running. This makes it run a lot more
slowly, however. Details of how to do this are given in the pcrebuild
documentation. When built in this way, instead of using the stack, PCRE
obtains and frees memory by calling the functions that are pointed to
- by the pcre_stack_malloc and pcre_stack_free variables. By default,
- these point to malloc() and free(), but you can replace the pointers to
- cause PCRE to use your own functions. Since the block sizes are always
- the same, and are always freed in reverse order, it may be possible to
- implement customized memory handlers that are more efficient than the
- standard functions.
+ by the pcre[16]_stack_malloc and pcre[16]_stack_free variables. By
+ default, these point to malloc() and free(), but you can replace the
+ pointers to cause PCRE to use your own functions. Since the block sizes
+ are always the same, and are always freed in reverse order, it may be
+ possible to implement customized memory handlers that are more effi-
+ cient than the standard functions.
- Limiting pcre_exec()'s stack usage
+ Limiting pcre[16]_exec()'s stack usage
You can set limits on the number of times that match() is called, both
- in total and recursively. If a limit is exceeded, pcre_exec() returns
- an error code. Setting suitable limits should prevent it from running
- out of stack. The default values of the limits are very large, and
- unlikely ever to operate. They can be changed when PCRE is built, and
- they can also be set when pcre_exec() is called. For details of these
- interfaces, see the pcrebuild documentation and the section on extra
- data for pcre_exec() in the pcreapi documentation.
+ in total and recursively. If a limit is exceeded, pcre[16]_exec()
+ returns an error code. Setting suitable limits should prevent it from
+ running out of stack. The default values of the limits are very large,
+ and unlikely ever to operate. They can be changed when PCRE is built,
+ and they can also be set when pcre[16]_exec() is called. For details of
+ these interfaces, see the pcrebuild documentation and the section on
+ extra data for pcre[16]_exec() in the pcreapi documentation.
As a very rough rule of thumb, you should reckon on about 500 bytes per
recursion. Thus, if you want to limit your stack usage to 8Mb, you
@@ -8417,7 +8938,7 @@ PCRE DISCUSSION OF STACK USAGE
option (-S) that can be used to increase the size of its stack. As long
as the stack is large enough, another option (-M) can be used to find
the smallest limits that allow a particular pattern to match a given
- subject string. This is done by calling pcre_exec() repeatedly with
+ subject string. This is done by calling pcre[16]_exec() repeatedly with
different limits.
Changing stack size in Unix-like systems
@@ -8440,7 +8961,7 @@ PCRE DISCUSSION OF STACK USAGE
This reads the current limits (soft and hard) using getrlimit(), then
attempts to increase the soft limit to 100Mb using setrlimit(). You
- must do this before calling pcre_exec().
+ must do this before calling pcre[16]_exec().
Changing stack size in Mac OS X
@@ -8459,8 +8980,8 @@ AUTHOR
REVISION
- Last updated: 26 August 2011
- Copyright (c) 1997-2011 University of Cambridge.
+ Last updated: 10 January 2012
+ Copyright (c) 1997-2012 University of Cambridge.
------------------------------------------------------------------------------
-
-
+
+
diff --git a/doc/pcresyntax.3 b/doc/pcresyntax.3
index e3111d4..f722892 100644
--- a/doc/pcresyntax.3
+++ b/doc/pcresyntax.3
@@ -413,7 +413,6 @@ The following act immediately they are reached:
(*FAIL) force backtrack; synonym (*F)
(*MARK:NAME) set name to be passed back; synonym (*:NAME)
.sp
-
The following act only when a subsequent match failure causes a backtrack to
reach them. They all force a match failure, but they differ in what happens
afterwards. Those that advance the start-of-match point do so only if the
diff --git a/doc/pcretest.txt b/doc/pcretest.txt
index 3835f48..383be92 100644
--- a/doc/pcretest.txt
+++ b/doc/pcretest.txt
@@ -14,56 +14,95 @@ SYNOPSIS
expressions. This document describes the features of the test program;
for details of the regular expressions themselves, see the pcrepattern
documentation. For details of the PCRE library function calls and their
- options, see the pcreapi documentation. The input for pcretest is a
- sequence of regular expression patterns and strings to be matched, as
- described below. The output shows the result of each match. Options on
- the command line and the patterns control PCRE options and exactly what
- is output.
+ options, see the pcreapi and pcre16 documentation. The input for
+ pcretest is a sequence of regular expression patterns and strings to be
+ matched, as described below. The output shows the result of each match.
+ Options on the command line and the patterns control PCRE options and
+ exactly what is output.
+
+
+PCRE's 8-BIT and 16-BIT LIBRARIES
+
+ From release 8.30, two separate PCRE libraries can be built. The origi-
+ nal one supports 8-bit character strings, whereas the newer 16-bit
+ library supports character strings encoded in 16-bit units. The
+ pcretest program can be used to test both libraries. However, it is
+ itself still an 8-bit program, reading 8-bit input and writing 8-bit
+ output. When testing the 16-bit library, the patterns and data strings
+ are converted to 16-bit format before being passed to the PCRE library
+ functions. Results are converted to 8-bit for output.
+
+ References to functions and structures of the form pcre[16]_xx below
+ mean "pcre_xx when using the 8-bit library or pcre16_xx when using the
+ 16-bit library".
COMMAND LINE OPTIONS
- -b Behave as if each pattern has the /B (show byte code) modi-
+ -16 If both the 8-bit and the 16-bit libraries have been built,
+ this option causes the 16-bit library to be used. If only the
+ 16-bit library has been built, this is the default (so has no
+ effect). If only the 8-bit library has been built, this
+ option causes an error.
+
+ -b Behave as if each pattern has the /B (show byte code) modi-
fier; the internal form is output after compilation.
-C Output the version number of the PCRE library, and all avail-
- able information about the optional features that are
- included, and then exit.
+ able information about the optional features that are
+ included, and then exit. All other options are ignored.
+
+ -C option Output information about a specific build-time option, then
+ exit. This functionality is intended for use in scripts such
+ as RunTest. The following options output the value indicated:
+
+ linksize the internal link size (2, 3, or 4)
+ newline the default newline setting:
+ CR, LF, CRLF, ANYCRLF, or ANY
+
+ The following options output 1 for true or zero for false:
- -d Behave as if each pattern has the /D (debug) modifier; the
- internal form and information about the compiled pattern is
+ jit just-in-time support is available
+ pcre16 the 16-bit library was built
+ pcre8 the 8-bit library was built
+ ucp Unicode property support is available
+ utf UTF-8 and/or UTF-16 support is available
+
+ -d Behave as if each pattern has the /D (debug) modifier; the
+ internal form and information about the compiled pattern is
output after compilation; -d is equivalent to -b -i.
- -dfa Behave as if each data line contains the \D escape sequence;
+ -dfa Behave as if each data line contains the \D escape sequence;
this causes the alternative matching function,
- pcre_dfa_exec(), to be used instead of the standard
- pcre_exec() function (more detail is given below).
+ pcre[16]_dfa_exec(), to be used instead of the standard
+ pcre[16]_exec() function (more detail is given below).
-help Output a brief summary these options and then exit.
- -i Behave as if each pattern has the /I modifier; information
+ -i Behave as if each pattern has the /I modifier; information
about the compiled pattern is given after compilation.
- -M Behave as if each data line contains the \M escape sequence;
- this causes PCRE to discover the minimum MATCH_LIMIT and
- MATCH_LIMIT_RECURSION settings by calling pcre_exec() repeat-
- edly with different limits.
+ -M Behave as if each data line contains the \M escape sequence;
+ this causes PCRE to discover the minimum MATCH_LIMIT and
+ MATCH_LIMIT_RECURSION settings by calling pcre[16]_exec()
+ repeatedly with different limits.
- -m Output the size of each compiled pattern after it has been
- compiled. This is equivalent to adding /M to each regular
- expression.
+ -m Output the size of each compiled pattern after it has been
+ compiled. This is equivalent to adding /M to each regular
+ expression. The size is given in bytes for both libraries.
- -o osize Set the number of elements in the output vector that is used
- when calling pcre_exec() or pcre_dfa_exec() to be osize. The
- default value is 45, which is enough for 14 capturing subex-
- pressions for pcre_exec() or 22 different matches for
- pcre_dfa_exec(). The vector size can be changed for individ-
- ual matching calls by including \O in the data line (see
- below).
+ -o osize Set the number of elements in the output vector that is used
+ when calling pcre[16]_exec() or pcre[16]_dfa_exec() to be
+ osize. The default value is 45, which is enough for 14 cap-
+ turing subexpressions for pcre[16]_exec() or 22 different
+ matches for pcre[16]_dfa_exec(). The vector size can be
+ changed for individual matching calls by including \O in the
+ data line (see below).
- -p Behave as if each pattern has the /P modifier; the POSIX
- wrapper API is used to call PCRE. None of the other options
- has any effect when -p is set.
+ -p Behave as if each pattern has the /P modifier; the POSIX
+ wrapper API is used to call PCRE. None of the other options
+ has any effect when -p is set. This option can be used only
+ with the 8-bit library.
-q Do not output the version number of pcretest at the start of
execution.
@@ -73,25 +112,27 @@ COMMAND LINE OPTIONS
-s or -s+ Behave as if each pattern has the /S modifier; in other
words, force each pattern to be studied. If -s+ is used, the
- PCRE_STUDY_JIT_COMPILE flag is passed to pcre_study(), caus-
- ing just-in-time optimization to be set up if it is avail-
- able. If the /I or /D option is present on a pattern
+ PCRE_STUDY_JIT_COMPILE flag is passed to pcre[16]_study(),
+ causing just-in-time optimization to be set up if it is
+ available. If the /I or /D option is present on a pattern
(requesting output about the compiled pattern), information
about the result of studying is not included when studying is
caused only by -s and neither -i nor -d is present on the
command line. This behaviour means that the output from tests
that are run with and without -s should be identical, except
when options that output information about the actual running
- of a match are set. The -M, -t, and -tm options, which give
- information about resources used, are likely to produce dif-
- ferent output with and without -s. Output may also differ if
- the /C option is present on an individual pattern. This uses
- callouts to trace the the matching process, and this may be
- different between studied and non-studied patterns. If the
- pattern contains (*MARK) items there may also be differences,
- for the same reason. The -s command line option can be over-
- ridden for specific patterns that should never be studied
- (see the /S pattern modifier below).
+ of a match are set.
+
+ The -M, -t, and -tm options, which give information about
+ resources used, are likely to produce different output with
+ and without -s. Output may also differ if the /C option is
+ present on an individual pattern. This uses callouts to trace
+ the the matching process, and this may be different between
+ studied and non-studied patterns. If the pattern contains
+ (*MARK) items there may also be differences, for the same
+ reason. The -s command line option can be overridden for spe-
+ cific patterns that should never be studied (see the /S pat-
+ tern modifier below).
-t Run each compile, study, and match many times with a timer,
and output resulting time per compile or match (in millisec-
@@ -173,7 +214,7 @@ PATTERN MODIFIERS
and the first modifier, and between the modifiers themselves.
The /i, /m, /s, and /x modifiers set the PCRE_CASELESS, PCRE_MULTILINE,
- PCRE_DOTALL, or PCRE_EXTENDED options, respectively, when pcre_com-
+ PCRE_DOTALL, or PCRE_EXTENDED options, respectively, when pcre[16]_com-
pile() is called. These four modifier letters have the same effect as
they do in Perl. For example:
@@ -182,8 +223,12 @@ PATTERN MODIFIERS
The following table shows additional modifiers for setting PCRE com-
pile-time options that do not correspond to anything in Perl:
- /8 PCRE_UTF8
- /? PCRE_NO_UTF8_CHECK
+ /8 PCRE_UTF8 ) when using the 8-bit
+ /? PCRE_NO_UTF8_CHECK ) library
+
+ /8 PCRE_UTF16 ) when using the 16-bit
+ /? PCRE_NO_UTF16_CHECK ) library
+
/A PCRE_ANCHORED
/C PCRE_AUTO_CALLOUT
/E PCRE_DOLLAR_ENDONLY
@@ -210,143 +255,147 @@ PATTERN MODIFIERS
/^abc/m<CRLF>
- As well as turning on the PCRE_UTF8 option, the /8 modifier also causes
- any non-printing characters in output strings to be printed using the
- \x{hh...} notation if they are valid UTF-8 sequences. Full details of
- the PCRE options are given in the pcreapi documentation.
+ As well as turning on the PCRE_UTF8/16 option, the /8 modifier causes
+ all non-printing characters in output strings to be printed using the
+ \x{hh...} notation. Otherwise, those less than 0x100 are output in hex
+ without the curly brackets.
+
+ Full details of the PCRE options are given in the pcreapi documenta-
+ tion.
Finding all matches in a string
- Searching for all possible matches within each subject string can be
- requested by the /g or /G modifier. After finding a match, PCRE is
+ Searching for all possible matches within each subject string can be
+ requested by the /g or /G modifier. After finding a match, PCRE is
called again to search the remainder of the subject string. The differ-
ence between /g and /G is that the former uses the startoffset argument
- to pcre_exec() to start searching at a new point within the entire
- string (which is in effect what Perl does), whereas the latter passes
- over a shortened substring. This makes a difference to the matching
+ to pcre[16]_exec() to start searching at a new point within the entire
+ string (which is in effect what Perl does), whereas the latter passes
+ over a shortened substring. This makes a difference to the matching
process if the pattern begins with a lookbehind assertion (including \b
or \B).
- If any call to pcre_exec() in a /g or /G sequence matches an empty
- string, the next call is done with the PCRE_NOTEMPTY_ATSTART and
- PCRE_ANCHORED flags set in order to search for another, non-empty,
- match at the same point. If this second match fails, the start offset
- is advanced, and the normal match is retried. This imitates the way
+ If any call to pcre[16]_exec() in a /g or /G sequence matches an empty
+ string, the next call is done with the PCRE_NOTEMPTY_ATSTART and
+ PCRE_ANCHORED flags set in order to search for another, non-empty,
+ match at the same point. If this second match fails, the start offset
+ is advanced, and the normal match is retried. This imitates the way
Perl handles such cases when using the /g modifier or the split() func-
- tion. Normally, the start offset is advanced by one character, but if
- the newline convention recognizes CRLF as a newline, and the current
+ tion. Normally, the start offset is advanced by one character, but if
+ the newline convention recognizes CRLF as a newline, and the current
character is CR followed by LF, an advance of two is used.
Other modifiers
There are yet more modifiers for controlling the way pcretest operates.
- The /+ modifier requests that as well as outputting the substring that
- matched the entire pattern, pcretest should in addition output the
- remainder of the subject string. This is useful for tests where the
- subject contains multiple copies of the same substring. If the + modi-
- fier appears twice, the same action is taken for captured substrings.
- In each case the remainder is output on the following line with a plus
- character following the capture number. Note that this modifier must
+ The /+ modifier requests that as well as outputting the substring that
+ matched the entire pattern, pcretest should in addition output the
+ remainder of the subject string. This is useful for tests where the
+ subject contains multiple copies of the same substring. If the + modi-
+ fier appears twice, the same action is taken for captured substrings.
+ In each case the remainder is output on the following line with a plus
+ character following the capture number. Note that this modifier must
not immediately follow the /S modifier because /S+ has another meaning.
- The /= modifier requests that the values of all potential captured
- parentheses be output after a match by pcre_exec(). By default, only
- those up to the highest one actually used in the match are output (cor-
- responding to the return code from pcre_exec()). Values in the offsets
- vector corresponding to higher numbers should be set to -1, and these
- are output as "<unset>". This modifier gives a way of checking that
- this is happening.
-
- The /B modifier is a debugging feature. It requests that pcretest out-
- put a representation of the compiled byte code after compilation. Nor-
- mally this information contains length and offset values; however, if
- /Z is also present, this data is replaced by spaces. This is a special
- feature for use in the automatic test scripts; it ensures that the same
+ The /= modifier requests that the values of all potential captured
+ parentheses be output after a match. By default, only those up to the
+ highest one actually used in the match are output (corresponding to the
+ return code from pcre[16]_exec()). Values in the offsets vector corre-
+ sponding to higher numbers should be set to -1, and these are output as
+ "<unset>". This modifier gives a way of checking that this is happen-
+ ing.
+
+ The /B modifier is a debugging feature. It requests that pcretest out-
+ put a representation of the compiled code after compilation. Normally
+ this information contains length and offset values; however, if /Z is
+ also present, this data is replaced by spaces. This is a special fea-
+ ture for use in the automatic test scripts; it ensures that the same
output is generated for different internal link sizes.
- The /D modifier is a PCRE debugging feature, and is equivalent to /BI,
+ The /D modifier is a PCRE debugging feature, and is equivalent to /BI,
that is, both the /B and the /I modifiers.
- The /F modifier causes pcretest to flip the byte order of the fields in
- the compiled pattern that contain 2-byte and 4-byte numbers. This
- facility is for testing the feature in PCRE that allows it to execute
- patterns that were compiled on a host with a different endianness. This
- feature is not available when the POSIX interface to PCRE is being
- used, that is, when the /P pattern modifier is specified. See also the
- section about saving and reloading compiled patterns below.
-
- The /I modifier requests that pcretest output information about the
- compiled pattern (whether it is anchored, has a fixed first character,
- and so on). It does this by calling pcre_fullinfo() after compiling a
- pattern. If the pattern is studied, the results of that are also out-
+ The /F modifier causes pcretest to flip the byte order of the 2-byte
+ and 4-byte fields in the compiled pattern. This facility is for testing
+ the feature in PCRE that allows it to execute patterns that were com-
+ piled on a host with a different endianness. This feature is not avail-
+ able when the POSIX interface to PCRE is being used, that is, when the
+ /P pattern modifier is specified. See also the section about saving and
+ reloading compiled patterns below.
+
+ The /I modifier requests that pcretest output information about the
+ compiled pattern (whether it is anchored, has a fixed first character,
+ and so on). It does this by calling pcre[16]_fullinfo() after compiling
+ a pattern. If the pattern is studied, the results of that are also out-
put.
- The /K modifier requests pcretest to show names from backtracking con-
- trol verbs that are returned from calls to pcre_exec(). It causes
- pcretest to create a pcre_extra block if one has not already been cre-
- ated by a call to pcre_study(), and to set the PCRE_EXTRA_MARK flag and
- the mark field within it, every time that pcre_exec() is called. If the
- variable that the mark field points to is non-NULL for a match, non-
- match, or partial match, pcretest prints the string to which it points.
- For a match, this is shown on a line by itself, tagged with "MK:". For
- a non-match it is added to the message.
-
- The /L modifier must be followed directly by the name of a locale, for
+ The /K modifier requests pcretest to show names from backtracking con-
+ trol verbs that are returned from calls to pcre[16]_exec(). It causes
+ pcretest to create a pcre[16]_extra block if one has not already been
+ created by a call to pcre[16]_study(), and to set the PCRE_EXTRA_MARK
+ flag and the mark field within it, every time that pcre[16]_exec() is
+ called. If the variable that the mark field points to is non-NULL for a
+ match, non-match, or partial match, pcretest prints the string to which
+ it points. For a match, this is shown on a line by itself, tagged with
+ "MK:". For a non-match it is added to the message.
+
+ The /L modifier must be followed directly by the name of a locale, for
example,
/pattern/Lfr_FR
For this reason, it must be the last modifier. The given locale is set,
- pcre_maketables() is called to build a set of character tables for the
- locale, and this is then passed to pcre_compile() when compiling the
- regular expression. Without an /L (or /T) modifier, NULL is passed as
- the tables pointer; that is, /L applies only to the expression on which
- it appears.
-
- The /M modifier causes the size of memory block used to hold the com-
- piled pattern to be output. This does not include the size of the pcre
- block; it is just the actual compiled data. If the pattern is success-
- fully studied with the PCRE_STUDY_JIT_COMPILE option, the size of the
- JIT compiled code is also output.
-
- If the /S modifier appears once, it causes pcre_study() to be called
- after the expression has been compiled, and the results used when the
- expression is matched. If /S appears twice, it suppresses studying,
- even if it was requested externally by the -s command line option. This
- makes it possible to specify that certain patterns are always studied,
- and others are never studied, independently of -s. This feature is used
- in the test files in a few cases where the output is different when the
- pattern is studied.
-
- If the /S modifier is immediately followed by a + character, the call
- to pcre_study() is made with the PCRE_STUDY_JIT_COMPILE option,
- requesting just-in-time optimization support if it is available. Note
- that there is also a /+ modifier; it must not be given immediately
- after /S because this will be misinterpreted. If JIT studying is suc-
- cessful, it will automatically be used when pcre_exec() is run, except
- when incompatible run-time options are specified. These include the
- partial matching options; a complete list is given in the pcrejit docu-
- mentation. See also the \J escape sequence below for a way of setting
- the size of the JIT stack.
-
- The /T modifier must be followed by a single digit. It causes a spe-
- cific set of built-in character tables to be passed to pcre_compile().
- It is used in the standard PCRE tests to check behaviour with different
- character tables. The digit specifies the tables as follows:
+ pcre[16]_maketables() is called to build a set of character tables for
+ the locale, and this is then passed to pcre[16]_compile() when compil-
+ ing the regular expression. Without an /L (or /T) modifier, NULL is
+ passed as the tables pointer; that is, /L applies only to the expres-
+ sion on which it appears.
+
+ The /M modifier causes the size in bytes of the memory block used to
+ hold the compiled pattern to be output. This does not include the size
+ of the pcre[16] block; it is just the actual compiled data. If the pat-
+ tern is successfully studied with the PCRE_STUDY_JIT_COMPILE option,
+ the size of the JIT compiled code is also output.
+
+ If the /S modifier appears once, it causes pcre[16]_study() to be
+ called after the expression has been compiled, and the results used
+ when the expression is matched. If /S appears twice, it suppresses
+ studying, even if it was requested externally by the -s command line
+ option. This makes it possible to specify that certain patterns are
+ always studied, and others are never studied, independently of -s. This
+ feature is used in the test files in a few cases where the output is
+ different when the pattern is studied.
+
+ If the /S modifier is immediately followed by a + character, the call
+ to pcre[16]_study() is made with the PCRE_STUDY_JIT_COMPILE option,
+ requesting just-in-time optimization support if it is available. Note
+ that there is also a /+ modifier; it must not be given immediately
+ after /S because this will be misinterpreted. If JIT studying is suc-
+ cessful, it will automatically be used when pcre[16]_exec() is run,
+ except when incompatible run-time options are specified. These include
+ the partial matching options; a complete list is given in the pcrejit
+ documentation. See also the \J escape sequence below for a way of set-
+ ting the size of the JIT stack.
+
+ The /T modifier must be followed by a single digit. It causes a spe-
+ cific set of built-in character tables to be passed to pcre[16]_com-
+ pile(). It is used in the standard PCRE tests to check behaviour with
+ different character tables. The digit specifies the tables as follows:
0 the default ASCII tables, as distributed in
pcre_chartables.c.dist
1 a set of tables defining ISO 8859 characters
- In table 1, some characters whose codes are greater than 128 are iden-
+ In table 1, some characters whose codes are greater than 128 are iden-
tified as letters, digits, spaces, etc.
Using the POSIX wrapper API
- The /P modifier causes pcretest to call PCRE via the POSIX wrapper API
- rather than its native API. When /P is set, the following modifiers set
- options for the regcomp() function:
+ The /P modifier causes pcretest to call PCRE via the POSIX wrapper API
+ rather than its native API. This supports only the 8-bit library. When
+ /P is set, the following modifiers set options for the regcomp() func-
+ tion:
/i REG_ICASE
/m REG_NEWLINE
@@ -362,12 +411,12 @@ PATTERN MODIFIERS
DATA LINES
- Before each data line is passed to pcre_exec(), leading and trailing
- white space is removed, and it is then scanned for \ escapes. Some of
- these are pretty esoteric features, intended for checking out some of
- the more complicated features of PCRE. If you are just testing "ordi-
- nary" regular expressions, you probably don't need any of these. The
- following escapes are recognized:
+ Before each data line is passed to pcre[16]_exec(), leading and trail-
+ ing white space is removed, and it is then scanned for \ escapes. Some
+ of these are pretty esoteric features, intended for checking out some
+ of the more complicated features of PCRE. If you are just testing
+ "ordinary" regular expressions, you probably don't need any of these.
+ The following escapes are recognized:
\a alarm (BEL, \x07)
\b backspace (\x08)
@@ -379,18 +428,17 @@ DATA LINES
\r carriage return (\x0d)
\t tab (\x09)
\v vertical tab (\x0b)
- \nnn octal character (up to 3 octal digits)
- always a byte unless > 255 in UTF-8 mode
+ \nnn octal character (up to 3 octal digits); always
+ a byte unless > 255 in UTF-8 or 16-bit mode
\xhh hexadecimal byte (up to 2 hex digits)
- \x{hh...} hexadecimal character, any number of digits
- in UTF-8 mode
- \A pass the PCRE_ANCHORED option to pcre_exec()
- or pcre_dfa_exec()
- \B pass the PCRE_NOTBOL option to pcre_exec()
- or pcre_dfa_exec()
- \Cdd call pcre_copy_substring() for substring dd
+ \x{hh...} hexadecimal character (any number of hex digits)
+ \A pass the PCRE_ANCHORED option to pcre[16]_exec()
+ or pcre[16]_dfa_exec()
+ \B pass the PCRE_NOTBOL option to pcre[16]_exec()
+ or pcre[16]_dfa_exec()
+ \Cdd call pcre[16]_copy_substring() for substring dd
after a successful match (number less than 32)
- \Cname call pcre_copy_named_substring() for substring
+ \Cname call pcre[16]_copy_named_substring() for substring
"name" after a successful match (name termin-
ated by next non alphanumeric character)
\C+ show the current captured substrings at callout
@@ -402,57 +450,65 @@ DATA LINES
reached for the nth time
\C*n pass the number n (may be negative) as callout
data; this is used as the callout return value
- \D use the pcre_dfa_exec() match function
- \F only shortest match for pcre_dfa_exec()
- \Gdd call pcre_get_substring() for substring dd
+ \D use the pcre[16]_dfa_exec() match function
+ \F only shortest match for pcre[16]_dfa_exec()
+ \Gdd call pcre[16]_get_substring() for substring dd
after a successful match (number less than 32)
- \Gname call pcre_get_named_substring() for substring
+ \Gname call pcre[16]_get_named_substring() for substring
"name" after a successful match (name termin-
ated by next non-alphanumeric character)
\Jdd set up a JIT stack of dd kilobytes maximum (any
number of digits)
- \L call pcre_get_substringlist() after a
+ \L call pcre[16]_get_substringlist() after a
successful match
\M discover the minimum MATCH_LIMIT and
MATCH_LIMIT_RECURSION settings
- \N pass the PCRE_NOTEMPTY option to pcre_exec()
- or pcre_dfa_exec(); if used twice, pass the
+ \N pass the PCRE_NOTEMPTY option to pcre[16]_exec()
+ or pcre[16]_dfa_exec(); if used twice, pass the
PCRE_NOTEMPTY_ATSTART option
\Odd set the size of the output vector passed to
- pcre_exec() to dd (any number of digits)
- \P pass the PCRE_PARTIAL_SOFT option to pcre_exec()
- or pcre_dfa_exec(); if used twice, pass the
+ pcre[16]_exec() to dd (any number of digits)
+ \P pass the PCRE_PARTIAL_SOFT option to pcre[16]_exec()
+ or pcre[16]_dfa_exec(); if used twice, pass the
PCRE_PARTIAL_HARD option
\Qdd set the PCRE_MATCH_LIMIT_RECURSION limit to dd
(any number of digits)
- \R pass the PCRE_DFA_RESTART option to pcre_dfa_exec()
+ \R pass the PCRE_DFA_RESTART option to pcre[16]_dfa_exec()
\S output details of memory get/free calls during matching
- \Y pass the PCRE_NO_START_OPTIMIZE option to pcre_exec()
- or pcre_dfa_exec()
- \Z pass the PCRE_NOTEOL option to pcre_exec()
- or pcre_dfa_exec()
- \? pass the PCRE_NO_UTF8_CHECK option to
- pcre_exec() or pcre_dfa_exec()
+ \Y pass the PCRE_NO_START_OPTIMIZE option to pcre[16]_exec()
+ or pcre[16]_dfa_exec()
+ \Z pass the PCRE_NOTEOL option to pcre[16]_exec()
+ or pcre[16]_dfa_exec()
+ \? pass the PCRE_NO_UTF[8|16]_CHECK option to
+ pcre[16]_exec() or pcre[16]_dfa_exec()
\>dd start the match at offset dd (optional "-"; then
any number of digits); this sets the startoffset
- argument for pcre_exec() or pcre_dfa_exec()
- \<cr> pass the PCRE_NEWLINE_CR option to pcre_exec()
- or pcre_dfa_exec()
- \<lf> pass the PCRE_NEWLINE_LF option to pcre_exec()
- or pcre_dfa_exec()
- \<crlf> pass the PCRE_NEWLINE_CRLF option to pcre_exec()
- or pcre_dfa_exec()
- \<anycrlf> pass the PCRE_NEWLINE_ANYCRLF option to pcre_exec()
- or pcre_dfa_exec()
- \<any> pass the PCRE_NEWLINE_ANY option to pcre_exec()
- or pcre_dfa_exec()
-
- Note that \xhh always specifies one byte, even in UTF-8 mode; this
- makes it possible to construct invalid UTF-8 sequences for testing pur-
- poses. On the other hand, \x{hh} is interpreted as a UTF-8 character in
- UTF-8 mode, generating more than one byte if the value is greater than
- 127. When not in UTF-8 mode, it generates one byte for values less than
- 256, and causes an error for greater values.
+ argument for pcre[16]_exec() or pcre[16]_dfa_exec()
+ \<cr> pass the PCRE_NEWLINE_CR option to pcre[16]_exec()
+ or pcre[16]_dfa_exec()
+ \<lf> pass the PCRE_NEWLINE_LF option to pcre[16]_exec()
+ or pcre[16]_dfa_exec()
+ \<crlf> pass the PCRE_NEWLINE_CRLF option to pcre[16]_exec()
+ or pcre[16]_dfa_exec()
+ \<anycrlf> pass the PCRE_NEWLINE_ANYCRLF option to pcre[16]_exec()
+ or pcre[16]_dfa_exec()
+ \<any> pass the PCRE_NEWLINE_ANY option to pcre[16]_exec()
+ or pcre[16]_dfa_exec()
+
+ The use of \x{hh...} is not dependent on the use of the /8 modifier on
+ the pattern. It is recognized always. There may be any number of hexa-
+ decimal digits inside the braces; invalid values provoke error mes-
+ sages.
+
+ Note that \xhh specifies one byte in UTF-8 mode; this makes it possible
+ to construct invalid UTF-8 sequences for testing purposes. On the other
+ hand, \x{hh} is interpreted as a UTF-8 character in UTF-8 mode, gener-
+ ating more than one byte if the value is greater than 127. When testing
+ the 8-bit library not in UTF-8 mode, \x{hh} generates one byte for val-
+ ues less than 256, and causes an error for greater values.
+
+ In UTF-16 mode, all 4-digit \x{hhhh} values are accepted. This makes it
+ possible to construct invalid UTF-16 sequences for testing purposes.
The escapes that specify line ending sequences are literal strings,
exactly as shown. No more than one newline setting should be present in
@@ -468,13 +524,13 @@ DATA LINES
mization is not being used. Providing a stack that is larger than the
default 32K is necessary only for very complicated patterns.
- If \M is present, pcretest calls pcre_exec() several times, with dif-
- ferent values in the match_limit and match_limit_recursion fields of
- the pcre_extra data structure, until it finds the minimum numbers for
- each parameter that allow pcre_exec() to complete without error.
- Because this is testing a specific feature of the normal interpretive
- pcre_exec() execution, the use of any JIT optimization that might have
- been set up by the /S+ qualifier of -s+ option is disabled.
+ If \M is present, pcretest calls pcre[16]_exec() several times, with
+ different values in the match_limit and match_limit_recursion fields of
+ the pcre[16]_extra data structure, until it finds the minimum numbers
+ for each parameter that allow pcre[16]_exec() to complete without
+ error. Because this is testing a specific feature of the normal inter-
+ pretive pcre[16]_exec() execution, the use of any JIT optimization that
+ might have been set up by the /S+ qualifier of -s+ option is disabled.
The match_limit number is a measure of the amount of backtracking that
takes place, and checking it out can be instructive. For most simple
@@ -487,56 +543,48 @@ DATA LINES
When \O is used, the value specified may be higher or lower than the
size set by the -O command line option (or defaulted to 45); \O applies
- only to the call of pcre_exec() for the line in which it appears.
+ only to the call of pcre[16]_exec() for the line in which it appears.
If the /P modifier was present on the pattern, causing the POSIX wrap-
per API to be used, the only option-setting sequences that have any
effect are \B, \N, and \Z, causing REG_NOTBOL, REG_NOTEMPTY, and
REG_NOTEOL, respectively, to be passed to regexec().
- The use of \x{hh...} to represent UTF-8 characters is not dependent on
- the use of the /8 modifier on the pattern. It is recognized always.
- There may be any number of hexadecimal digits inside the braces. The
- result is from one to six bytes, encoded according to the original
- UTF-8 rules of RFC 2279. This allows for values in the range 0 to
- 0x7FFFFFFF. Note that not all of those are valid Unicode code points,
- or indeed valid UTF-8 characters according to the later rules in RFC
- 3629.
-
THE ALTERNATIVE MATCHING FUNCTION
- By default, pcretest uses the standard PCRE matching function,
- pcre_exec() to match each data line. From release 6.0, PCRE supports an
- alternative matching function, pcre_dfa_test(), which operates in a
- different way, and has some restrictions. The differences between the
- two functions are described in the pcrematching documentation.
+ By default, pcretest uses the standard PCRE matching function,
+ pcre[16]_exec() to match each data line. PCRE also supports an alterna-
+ tive matching function, pcre[16]_dfa_test(), which operates in a dif-
+ ferent way, and has some restrictions. The differences between the two
+ functions are described in the pcrematching documentation.
- If a data line contains the \D escape sequence, or if the command line
- contains the -dfa option, the alternative matching function is called.
+ If a data line contains the \D escape sequence, or if the command line
+ contains the -dfa option, the alternative matching function is used.
This function finds all possible matches at a given point. If, however,
- the \F escape sequence is present in the data line, it stops after the
+ the \F escape sequence is present in the data line, it stops after the
first match is found. This is always the shortest possible match.
DEFAULT OUTPUT FROM PCRETEST
- This section describes the output when the normal matching function,
- pcre_exec(), is being used.
+ This section describes the output when the normal matching function,
+ pcre[16]_exec(), is being used.
When a match succeeds, pcretest outputs the list of captured substrings
- that pcre_exec() returns, starting with number 0 for the string that
- matched the whole pattern. Otherwise, it outputs "No match" when the
- return is PCRE_ERROR_NOMATCH, and "Partial match:" followed by the par-
- tially matching substring when pcre_exec() returns PCRE_ERROR_PARTIAL.
- (Note that this is the entire substring that was inspected during the
- partial match; it may include characters before the actual match start
- if a lookbehind assertion, \K, \b, or \B was involved.) For any other
- return, pcretest outputs the PCRE negative error number and a short
- descriptive phrase. If the error is a failed UTF-8 string check, the
- byte offset of the start of the failing character and the reason code
- are also output, provided that the size of the output vector is at
- least two. Here is an example of an interactive pcretest run.
+ that pcre[16]_exec() returns, starting with number 0 for the string
+ that matched the whole pattern. Otherwise, it outputs "No match" when
+ the return is PCRE_ERROR_NOMATCH, and "Partial match:" followed by the
+ partially matching substring when pcre[16]_exec() returns
+ PCRE_ERROR_PARTIAL. (Note that this is the entire substring that was
+ inspected during the partial match; it may include characters before
+ the actual match start if a lookbehind assertion, \K, \b, or \B was
+ involved.) For any other return, pcretest outputs the PCRE negative
+ error number and a short descriptive phrase. If the error is a failed
+ UTF string check, the offset of the start of the failing character and
+ the reason code are also output, provided that the size of the output
+ vector is at least two. Here is an example of an interactive pcretest
+ run.
$ pcretest
PCRE version 8.13 2011-04-30
@@ -549,10 +597,10 @@ DEFAULT OUTPUT FROM PCRETEST
No match
Unset capturing substrings that are not followed by one that is set are
- not returned by pcre_exec(), and are not shown by pcretest. In the fol-
- lowing example, there are two capturing substrings, but when the first
- data line is matched, the second, unset substring is not shown. An
- "internal" unset substring is shown as "<unset>", as for the second
+ not returned by pcre[16]_exec(), and are not shown by pcretest. In the
+ following example, there are two capturing substrings, but when the
+ first data line is matched, the second, unset substring is not shown.
+ An "internal" unset substring is shown as "<unset>", as for the second
data line.
re> /(a)|(b)/
@@ -565,11 +613,11 @@ DEFAULT OUTPUT FROM PCRETEST
2: b
If the strings contain any non-printing characters, they are output as
- \0x escapes, or as \x{...} escapes if the /8 modifier was present on
- the pattern. See below for the definition of non-printing characters.
- If the pattern has the /+ modifier, the output for substring 0 is fol-
- lowed by the the rest of the subject string, identified by "0+" like
- this:
+ \xhh escapes if the value is less than 256 and UTF mode is not set.
+ Otherwise they are output as \x{hh...} escapes. See below for the defi-
+ nition of non-printing characters. If the pattern has the /+ modifier,
+ the output for substring 0 is followed by the the rest of the subject
+ string, identified by "0+" like this:
re> /cat/+
data> cataract
@@ -611,10 +659,11 @@ DEFAULT OUTPUT FROM PCRETEST
OUTPUT FROM THE ALTERNATIVE MATCHING FUNCTION
- When the alternative matching function, pcre_dfa_exec(), is used (by
- means of the \D escape sequence or the -dfa command line option), the
- output consists of a list of all the matches that start at the first
- point in the subject where there is at least one match. For example:
+ When the alternative matching function, pcre[16]_dfa_exec(), is used
+ (by means of the \D escape sequence or the -dfa command line option),
+ the output consists of a list of all the matches that start at the
+ first point in the subject where there is at least one match. For exam-
+ ple:
re> /(tang|tangerine|tan)/
data> yellow tangerine\D
@@ -622,11 +671,11 @@ OUTPUT FROM THE ALTERNATIVE MATCHING FUNCTION
1: tang
2: tan
- (Using the normal matching function on this data finds only "tang".)
- The longest matching string is always given first (and numbered zero).
+ (Using the normal matching function on this data finds only "tang".)
+ The longest matching string is always given first (and numbered zero).
After a PCRE_ERROR_PARTIAL return, the output is "Partial match:", fol-
- lowed by the partially matching substring. (Note that this is the
- entire substring that was inspected during the partial match; it may
+ lowed by the partially matching substring. (Note that this is the
+ entire substring that was inspected during the partial match; it may
include characters before the actual match start if a lookbehind asser-
tion, \K, \b, or \B was involved.)
@@ -642,16 +691,16 @@ OUTPUT FROM THE ALTERNATIVE MATCHING FUNCTION
1: tan
0: tan
- Since the matching function does not support substring capture, the
- escape sequences that are concerned with captured substrings are not
+ Since the matching function does not support substring capture, the
+ escape sequences that are concerned with captured substrings are not
relevant.
RESTARTING AFTER A PARTIAL MATCH
When the alternative matching function has given the PCRE_ERROR_PARTIAL
- return, indicating that the subject partially matched the pattern, you
- can restart the match with additional subject data by means of the \R
+ return, indicating that the subject partially matched the pattern, you
+ can restart the match with additional subject data by means of the \R
escape sequence. For example:
re> /^\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d$/
@@ -660,30 +709,30 @@ RESTARTING AFTER A PARTIAL MATCH
data> n05\R\D
0: n05
- For further information about partial matching, see the pcrepartial
+ For further information about partial matching, see the pcrepartial
documentation.
CALLOUTS
- If the pattern contains any callout requests, pcretest's callout func-
- tion is called during matching. This works with both matching func-
+ If the pattern contains any callout requests, pcretest's callout func-
+ tion is called during matching. This works with both matching func-
tions. By default, the called function displays the callout number, the
- start and current positions in the text at the callout time, and the
- next pattern item to be tested. For example, the output
+ start and current positions in the text at the callout time, and the
+ next pattern item to be tested. For example:
--->pqrabcdef
0 ^ ^ \d
- indicates that callout number 0 occurred for a match attempt starting
- at the fourth character of the subject string, when the pointer was at
- the seventh character of the data, and when the next pattern item was
- \d. Just one circumflex is output if the start and current positions
- are the same.
+ This output indicates that callout number 0 occurred for a match
+ attempt starting at the fourth character of the subject string, when
+ the pointer was at the seventh character of the data, and when the next
+ pattern item was \d. Just one circumflex is output if the start and
+ current positions are the same.
Callouts numbered 255 are assumed to be automatic callouts, inserted as
- a result of the /C pattern modifier. In this case, instead of showing
- the callout number, the offset in the pattern, preceded by a plus, is
+ a result of the /C pattern modifier. In this case, instead of showing
+ the callout number, the offset in the pattern, preceded by a plus, is
output. For example:
re> /\d?[A-E]\*/C
@@ -696,7 +745,7 @@ CALLOUTS
0: E*
If a pattern contains (*MARK) items, an additional line is output when-
- ever a change of latest mark is passed to the callout function. For
+ ever a change of latest mark is passed to the callout function. For
example:
re> /a(*MARK:X)bc/C
@@ -710,59 +759,59 @@ CALLOUTS
+12 ^ ^
0: abc
- The mark changes between matching "a" and "b", but stays the same for
- the rest of the match, so nothing more is output. If, as a result of
- backtracking, the mark reverts to being unset, the text "<unset>" is
+ The mark changes between matching "a" and "b", but stays the same for
+ the rest of the match, so nothing more is output. If, as a result of
+ backtracking, the mark reverts to being unset, the text "<unset>" is
output.
- The callout function in pcretest returns zero (carry on matching) by
- default, but you can use a \C item in a data line (as described above)
+ The callout function in pcretest returns zero (carry on matching) by
+ default, but you can use a \C item in a data line (as described above)
to change this and other parameters of the callout.
- Inserting callouts can be helpful when using pcretest to check compli-
- cated regular expressions. For further information about callouts, see
+ Inserting callouts can be helpful when using pcretest to check compli-
+ cated regular expressions. For further information about callouts, see
the pcrecallout documentation.
NON-PRINTING CHARACTERS
- When pcretest is outputting text in the compiled version of a pattern,
- bytes other than 32-126 are always treated as non-printing characters
+ When pcretest is outputting text in the compiled version of a pattern,
+ bytes other than 32-126 are always treated as non-printing characters
are are therefore shown as hex escapes.
- When pcretest is outputting text that is a matched part of a subject
- string, it behaves in the same way, unless a different locale has been
- set for the pattern (using the /L modifier). In this case, the
+ When pcretest is outputting text that is a matched part of a subject
+ string, it behaves in the same way, unless a different locale has been
+ set for the pattern (using the /L modifier). In this case, the
isprint() function to distinguish printing and non-printing characters.
SAVING AND RELOADING COMPILED PATTERNS
- The facilities described in this section are not available when the
- POSIX interface to PCRE is being used, that is, when the /P pattern
+ The facilities described in this section are not available when the
+ POSIX interface to PCRE is being used, that is, when the /P pattern
modifier is specified.
When the POSIX interface is not in use, you can cause pcretest to write
- a compiled pattern to a file, by following the modifiers with > and a
+ a compiled pattern to a file, by following the modifiers with > and a
file name. For example:
/pattern/im >/some/file
- See the pcreprecompile documentation for a discussion about saving and
- re-using compiled patterns. Note that if the pattern was successfully
+ See the pcreprecompile documentation for a discussion about saving and
+ re-using compiled patterns. Note that if the pattern was successfully
studied with JIT optimization, the JIT data cannot be saved.
- The data that is written is binary. The first eight bytes are the
- length of the compiled pattern data followed by the length of the
- optional study data, each written as four bytes in big-endian order
- (most significant byte first). If there is no study data (either the
+ The data that is written is binary. The first eight bytes are the
+ length of the compiled pattern data followed by the length of the
+ optional study data, each written as four bytes in big-endian order
+ (most significant byte first). If there is no study data (either the
pattern was not studied, or studying did not return any data), the sec-
- ond length is zero. The lengths are followed by an exact copy of the
- compiled pattern. If there is additional study data, this (excluding
- any JIT data) follows immediately after the compiled pattern. After
+ ond length is zero. The lengths are followed by an exact copy of the
+ compiled pattern. If there is additional study data, this (excluding
+ any JIT data) follows immediately after the compiled pattern. After
writing the file, pcretest expects to read a new pattern.
- A saved pattern can be reloaded into pcretest by specifying < and a
+ A saved pattern can be reloaded into pcretest by specifying < and a
file name instead of a pattern. The name of the file must not contain a
< character, as otherwise pcretest will interpret the line as a pattern
delimited by < characters. For example:
@@ -771,15 +820,24 @@ SAVING AND RELOADING COMPILED PATTERNS
Compiled pattern loaded from /some/file
No study data
- If the pattern was previously studied with the JIT optimization, the
- JIT information cannot be saved and restored, and so is lost. When the
- pattern has been loaded, pcretest proceeds to read data lines in the
+ If the pattern was previously studied with the JIT optimization, the
+ JIT information cannot be saved and restored, and so is lost. When the
+ pattern has been loaded, pcretest proceeds to read data lines in the
usual way.
- You can copy a file written by pcretest to a different host and reload
- it there, even if the new host has opposite endianness to the one on
- which the pattern was compiled. For example, you can compile on an i86
- machine and run on a SPARC machine.
+ You can copy a file written by pcretest to a different host and reload
+ it there, even if the new host has opposite endianness to the one on
+ which the pattern was compiled. For example, you can compile on an i86
+ machine and run on a SPARC machine. When a pattern is reloaded on a
+ host with different endianness, the confirmation message is changed to:
+
+ Compiled pattern (byte-inverted) loaded from /some/file
+
+ The test suite contains some saved pre-compiled patterns with different
+ endianness. These are reloaded using "<!" instead of just "<". This
+ suppresses the "(byte-inverted)" text so that the output is the same on
+ all hosts. It also forces debugging output once the pattern has been
+ reloaded.
File names for saving and reloading can be absolute or relative, but
note that the shell facility of expanding a file name that starts with
@@ -797,8 +855,8 @@ SAVING AND RELOADING COMPILED PATTERNS
SEE ALSO
- pcre(3), pcreapi(3), pcrecallout(3), pcrejit, pcrematching(3), pcrepar-
- tial(d), pcrepattern(3), pcreprecompile(3).
+ pcre(3), pcre16(3), pcreapi(3), pcrecallout(3), pcrejit, pcrematch-
+ ing(3), pcrepartial(d), pcrepattern(3), pcreprecompile(3).
AUTHOR
@@ -810,5 +868,5 @@ AUTHOR
REVISION
- Last updated: 02 December 2011
- Copyright (c) 1997-2011 University of Cambridge.
+ Last updated: 13 January 2012
+ Copyright (c) 1997-2012 University of Cambridge.