Remove obsolete pcre code
[privoxy.git] / pcre / doc / pcre.3
diff --git a/pcre/doc/pcre.3 b/pcre/doc/pcre.3
deleted file mode 100644 (file)
index bb812f4..0000000
+++ /dev/null
@@ -1,1810 +0,0 @@
-.TH PCRE 3\r
-.SH NAME\r
-pcre - Perl-compatible regular expressions.\r
-.SH SYNOPSIS\r
-.B #include <pcre.h>\r
-.PP\r
-.SM\r
-.br\r
-.B pcre *pcre_compile(const char *\fIpattern\fR, int \fIoptions\fR,\r
-.ti +5n\r
-.B const char **\fIerrptr\fR, int *\fIerroffset\fR,\r
-.ti +5n\r
-.B const unsigned char *\fItableptr\fR);\r
-.PP\r
-.br\r
-.B pcre_extra *pcre_study(const pcre *\fIcode\fR, int \fIoptions\fR,\r
-.ti +5n\r
-.B const char **\fIerrptr\fR);\r
-.PP\r
-.br\r
-.B int pcre_exec(const pcre *\fIcode\fR, "const pcre_extra *\fIextra\fR,"\r
-.ti +5n\r
-.B "const char *\fIsubject\fR," int \fIlength\fR, int \fIstartoffset\fR,\r
-.ti +5n\r
-.B int \fIoptions\fR, int *\fIovector\fR, int \fIovecsize\fR);\r
-.PP\r
-.br\r
-.B int pcre_copy_substring(const char *\fIsubject\fR, int *\fIovector\fR,\r
-.ti +5n\r
-.B int \fIstringcount\fR, int \fIstringnumber\fR, char *\fIbuffer\fR,\r
-.ti +5n\r
-.B int \fIbuffersize\fR);\r
-.PP\r
-.br\r
-.B int pcre_get_substring(const char *\fIsubject\fR, int *\fIovector\fR,\r
-.ti +5n\r
-.B int \fIstringcount\fR, int \fIstringnumber\fR,\r
-.ti +5n\r
-.B const char **\fIstringptr\fR);\r
-.PP\r
-.br\r
-.B int pcre_get_substring_list(const char *\fIsubject\fR,\r
-.ti +5n\r
-.B int *\fIovector\fR, int \fIstringcount\fR, "const char ***\fIlistptr\fR);"\r
-.PP\r
-.br\r
-.B void pcre_free_substring(const char *\fIstringptr\fR);\r
-.PP\r
-.br\r
-.B void pcre_free_substring_list(const char **\fIstringptr\fR);\r
-.PP\r
-.br\r
-.B const unsigned char *pcre_maketables(void);\r
-.PP\r
-.br\r
-.B int pcre_fullinfo(const pcre *\fIcode\fR, "const pcre_extra *\fIextra\fR,"\r
-.ti +5n\r
-.B int \fIwhat\fR, void *\fIwhere\fR);\r
-.PP\r
-.br\r
-.B int pcre_info(const pcre *\fIcode\fR, int *\fIoptptr\fR, int\r
-.B *\fIfirstcharptr\fR);\r
-.PP\r
-.br\r
-.B char *pcre_version(void);\r
-.PP\r
-.br\r
-.B void *(*pcre_malloc)(size_t);\r
-.PP\r
-.br\r
-.B void (*pcre_free)(void *);\r
-\r
-\r
-\r
-.SH DESCRIPTION\r
-The PCRE library is a set of functions that implement regular expression\r
-pattern matching using the same syntax and semantics as Perl 5, with just a few\r
-differences (see below). The current implementation corresponds to Perl 5.005,\r
-with some additional features from later versions. This includes some\r
-experimental, incomplete support for UTF-8 encoded strings. Details of exactly\r
-what is and what is not supported are given below.\r
-\r
-PCRE has its own native API, which is described in this document. There is also\r
-a set of wrapper functions that correspond to the POSIX regular expression API.\r
-These are described in the \fBpcreposix\fR documentation.\r
-\r
-The native API function prototypes are defined in the header file \fBpcre.h\fR,\r
-and on Unix systems the library itself is called \fBlibpcre.a\fR, so can be\r
-accessed by adding \fB-lpcre\fR to the command for linking an application which\r
-calls it. The header file defines the macros PCRE_MAJOR and PCRE_MINOR to\r
-contain the major and minor release numbers for the library. Applications can\r
-use these to include support for different releases.\r
-\r
-The functions \fBpcre_compile()\fR, \fBpcre_study()\fR, and \fBpcre_exec()\fR\r
-are used for compiling and matching regular expressions.\r
-\r
-The functions \fBpcre_copy_substring()\fR, \fBpcre_get_substring()\fR, and\r
-\fBpcre_get_substring_list()\fR are convenience functions for extracting\r
-captured substrings from a matched subject string; \fBpcre_free_substring()\fR\r
-and \fBpcre_free_substring_list()\fR are also provided, to free the memory used\r
-for extracted strings.\r
-\r
-The function \fBpcre_maketables()\fR is used (optionally) to build a set of\r
-character tables in the current locale for passing to \fBpcre_compile()\fR.\r
-\r
-The function \fBpcre_fullinfo()\fR is used to find out information about a\r
-compiled pattern; \fBpcre_info()\fR is an obsolete version which returns only\r
-some of the available information, but is retained for backwards compatibility.\r
-The function \fBpcre_version()\fR returns a pointer to a string containing the\r
-version of PCRE and its date of release.\r
-\r
-The global variables \fBpcre_malloc\fR and \fBpcre_free\fR initially contain\r
-the entry points of the standard \fBmalloc()\fR and \fBfree()\fR functions\r
-respectively. PCRE calls the memory management functions via these variables,\r
-so a calling program can replace them if it wishes to intercept the calls. This\r
-should be done before calling any PCRE functions.\r
-\r
-\r
-.SH MULTI-THREADING\r
-The PCRE functions can be used in multi-threading applications, with the\r
-proviso that the memory management functions pointed to by \fBpcre_malloc\fR\r
-and \fBpcre_free\fR are shared by all threads.\r
-\r
-The compiled form of a regular expression is not altered during matching, so\r
-the same compiled pattern can safely be used by several threads at once.\r
-\r
-\r
-.SH COMPILING A PATTERN\r
-The function \fBpcre_compile()\fR is called to compile a pattern into an\r
-internal form. The pattern is a C string terminated by a binary zero, and\r
-is passed in the argument \fIpattern\fR. A pointer to a single block of memory\r
-that is obtained via \fBpcre_malloc\fR is returned. This contains the\r
-compiled code and related data. The \fBpcre\fR type is defined for this for\r
-convenience, but in fact \fBpcre\fR is just a typedef for \fBvoid\fR, since the\r
-contents of the block are not externally defined. It is up to the caller to\r
-free the memory when it is no longer required.\r
-.PP\r
-The size of a compiled pattern is roughly proportional to the length of the\r
-pattern string, except that each character class (other than those containing\r
-just a single character, negated or not) requires 33 bytes, and repeat\r
-quantifiers with a minimum greater than one or a bounded maximum cause the\r
-relevant portions of the compiled pattern to be replicated.\r
-.PP\r
-The \fIoptions\fR argument contains independent bits that affect the\r
-compilation. It should be zero if no options are required. Some of the options,\r
-in particular, those that are compatible with Perl, can also be set and unset\r
-from within the pattern (see the detailed description of regular expressions\r
-below). For these options, the contents of the \fIoptions\fR argument specifies\r
-their initial settings at the start of compilation and execution. The\r
-PCRE_ANCHORED option can be set at the time of matching as well as at compile\r
-time.\r
-.PP\r
-If \fIerrptr\fR is NULL, \fBpcre_compile()\fR returns NULL immediately.\r
-Otherwise, if compilation of a pattern fails, \fBpcre_compile()\fR returns\r
-NULL, and sets the variable pointed to by \fIerrptr\fR to point to a textual\r
-error message. The offset from the start of the pattern to the character where\r
-the error was discovered is placed in the variable pointed to by\r
-\fIerroffset\fR, which must not be NULL. If it is, an immediate error is given.\r
-.PP\r
-If the final argument, \fItableptr\fR, is NULL, PCRE uses a default set of\r
-character tables which are built when it is compiled, using the default C\r
-locale. Otherwise, \fItableptr\fR must be the result of a call to\r
-\fBpcre_maketables()\fR. See the section on locale support below.\r
-.PP\r
-The following option bits are defined in the header file:\r
-\r
-  PCRE_ANCHORED\r
-\r
-If this bit is set, the pattern is forced to be "anchored", that is, it is\r
-constrained to match only at the start of the string which is being searched\r
-(the "subject string"). This effect can also be achieved by appropriate\r
-constructs in the pattern itself, which is the only way to do it in Perl.\r
-\r
-  PCRE_CASELESS\r
-\r
-If this bit is set, letters in the pattern match both upper and lower case\r
-letters. It is equivalent to Perl's /i option.\r
-\r
-  PCRE_DOLLAR_ENDONLY\r
-\r
-If this bit is set, a dollar metacharacter in the pattern matches only at the\r
-end of the subject string. Without this option, a dollar also matches\r
-immediately before the final character if it is a newline (but not before any\r
-other newlines). The PCRE_DOLLAR_ENDONLY option is ignored if PCRE_MULTILINE is\r
-set. There is no equivalent to this option in Perl.\r
-\r
-  PCRE_DOTALL\r
-\r
-If this bit is set, a dot metacharater in the pattern matches all characters,\r
-including newlines. Without it, newlines are excluded. This option is\r
-equivalent to Perl's /s option. A negative class such as [^a] always matches a\r
-newline character, independent of the setting of this option.\r
-\r
-  PCRE_EXTENDED\r
-\r
-If this bit is set, whitespace data characters in the pattern are totally\r
-ignored except when escaped or inside a character class, and characters between\r
-an unescaped # outside a character class and the next newline character,\r
-inclusive, are also ignored. This is equivalent to Perl's /x option, and makes\r
-it possible to include comments inside complicated patterns. Note, however,\r
-that this applies only to data characters. Whitespace characters may never\r
-appear within special character sequences in a pattern, for example within the\r
-sequence (?( which introduces a conditional subpattern.\r
-\r
-  PCRE_EXTRA\r
-\r
-This option was invented in order to turn on additional functionality of PCRE\r
-that is incompatible with Perl, but it is currently of very little use. When\r
-set, any backslash in a pattern that is followed by a letter that has no\r
-special meaning causes an error, thus reserving these combinations for future\r
-expansion. By default, as in Perl, a backslash followed by a letter with no\r
-special meaning is treated as a literal. There are at present no other features\r
-controlled by this option. It can also be set by a (?X) option setting within a\r
-pattern.\r
-\r
-  PCRE_MULTILINE\r
-\r
-By default, PCRE treats the subject string as consisting of a single "line" of\r
-characters (even if it actually contains several newlines). The "start of line"\r
-metacharacter (^) matches only at the start of the string, while the "end of\r
-line" metacharacter ($) matches only at the end of the string, or before a\r
-terminating newline (unless PCRE_DOLLAR_ENDONLY is set). This is the same as\r
-Perl.\r
-\r
-When PCRE_MULTILINE it is set, the "start of line" and "end of line" constructs\r
-match immediately following or immediately before any newline in the subject\r
-string, respectively, as well as at the very start and end. This is equivalent\r
-to Perl's /m option. If there are no "\\n" characters in a subject string, or\r
-no occurrences of ^ or $ in a pattern, setting PCRE_MULTILINE has no\r
-effect.\r
-\r
-  PCRE_UNGREEDY\r
-\r
-This option inverts the "greediness" of the quantifiers so that they are not\r
-greedy by default, but become greedy if followed by "?". It is not compatible\r
-with Perl. It can also be set by a (?U) option setting within the pattern.\r
-\r
-  PCRE_UTF8\r
-\r
-This option causes PCRE to regard both the pattern and the subject as strings\r
-of UTF-8 characters instead of just byte strings. However, it is available only\r
-if PCRE has been built to include UTF-8 support. If not, the use of this option\r
-provokes an error. Support for UTF-8 is new, experimental, and incomplete.\r
-Details of exactly what it entails are given below.\r
-\r
-\r
-.SH STUDYING A PATTERN\r
-When a pattern is going to be used several times, it is worth spending more\r
-time analyzing it in order to speed up the time taken for matching. The\r
-function \fBpcre_study()\fR takes a pointer to a compiled pattern as its first\r
-argument, and returns a pointer to a \fBpcre_extra\fR block (another \fBvoid\fR\r
-typedef) containing additional information about the pattern; this can be\r
-passed to \fBpcre_exec()\fR. If no additional information is available, NULL\r
-is returned.\r
-\r
-The second argument contains option bits. At present, no options are defined\r
-for \fBpcre_study()\fR, and this argument should always be zero.\r
-\r
-The third argument for \fBpcre_study()\fR is a pointer to an error message. If\r
-studying succeeds (even if no data is returned), the variable it points to is\r
-set to NULL. Otherwise it points to a textual error message.\r
-\r
-At present, studying a pattern is useful only for non-anchored patterns that do\r
-not have a single fixed starting character. A bitmap of possible starting\r
-characters is created.\r
-\r
-\r
-.SH LOCALE SUPPORT\r
-PCRE handles caseless matching, and determines whether characters are letters,\r
-digits, or whatever, by reference to a set of tables. The library contains a\r
-default set of tables which is created in the default C locale when PCRE is\r
-compiled. This is used when the final argument of \fBpcre_compile()\fR is NULL,\r
-and is sufficient for many applications.\r
-\r
-An alternative set of tables can, however, be supplied. Such tables are built\r
-by calling the \fBpcre_maketables()\fR function, which has no arguments, in the\r
-relevant locale. The result can then be passed to \fBpcre_compile()\fR as often\r
-as necessary. For example, to build and use tables that are appropriate for the\r
-French locale (where accented characters with codes greater than 128 are\r
-treated as letters), the following code could be used:\r
-\r
-  setlocale(LC_CTYPE, "fr");\r
-  tables = pcre_maketables();\r
-  re = pcre_compile(..., tables);\r
-\r
-The tables are built in memory that is obtained via \fBpcre_malloc\fR. The\r
-pointer that is passed to \fBpcre_compile\fR is saved with the compiled\r
-pattern, and the same tables are used via this pointer by \fBpcre_study()\fR\r
-and \fBpcre_exec()\fR. Thus for any single pattern, compilation, studying and\r
-matching all happen in the same locale, but different patterns can be compiled\r
-in different locales. It is the caller's responsibility to ensure that the\r
-memory containing the tables remains available for as long as it is needed.\r
-\r
-\r
-.SH INFORMATION ABOUT A PATTERN\r
-The \fBpcre_fullinfo()\fR function returns information about a compiled\r
-pattern. It replaces the obsolete \fBpcre_info()\fR function, which is\r
-nevertheless retained for backwards compability (and is documented below).\r
-\r
-The first argument for \fBpcre_fullinfo()\fR is a pointer to the compiled\r
-pattern. The second argument is the result of \fBpcre_study()\fR, or NULL if\r
-the pattern was not studied. The third argument specifies which piece of\r
-information is required, while the fourth argument is a pointer to a variable\r
-to receive the data. The yield of the function is zero for success, or one of\r
-the following negative numbers:\r
-\r
-  PCRE_ERROR_NULL       the argument \fIcode\fR was NULL\r
-                        the argument \fIwhere\fR was NULL\r
-  PCRE_ERROR_BADMAGIC   the "magic number" was not found\r
-  PCRE_ERROR_BADOPTION  the value of \fIwhat\fR was invalid\r
-\r
-The possible values for the third argument are defined in \fBpcre.h\fR, and are\r
-as follows:\r
-\r
-  PCRE_INFO_OPTIONS\r
-\r
-Return a copy of the options with which the pattern was compiled. The fourth\r
-argument should point to au \fBunsigned long int\fR variable. These option bits\r
-are those specified in the call to \fBpcre_compile()\fR, modified by any\r
-top-level option settings within the pattern itself, and with the PCRE_ANCHORED\r
-bit forcibly set if the form of the pattern implies that it can match only at\r
-the start of a subject string.\r
-\r
-  PCRE_INFO_SIZE\r
-\r
-Return the size of the compiled pattern, that is, the value that was passed as\r
-the argument to \fBpcre_malloc()\fR when PCRE was getting memory in which to\r
-place the compiled data. The fourth argument should point to a \fBsize_t\fR\r
-variable.\r
-\r
-  PCRE_INFO_CAPTURECOUNT\r
-\r
-Return the number of capturing subpatterns in the pattern. The fourth argument\r
-should point to an \fbint\fR variable.\r
-\r
-  PCRE_INFO_BACKREFMAX\r
-\r
-Return the number of the highest back reference in the pattern. The fourth\r
-argument should point to an \fBint\fR variable. Zero is returned if there are\r
-no back references.\r
-\r
-  PCRE_INFO_FIRSTCHAR\r
-\r
-Return information about the first character of any matched string, for a\r
-non-anchored pattern. If there is a fixed first character, e.g. from a pattern\r
-such as (cat|cow|coyote), it is returned in the integer pointed to by\r
-\fIwhere\fR. Otherwise, if either\r
-\r
-(a) the pattern was compiled with the PCRE_MULTILINE option, and every branch\r
-starts with "^", or\r
-\r
-(b) every branch of the pattern starts with ".*" and PCRE_DOTALL is not set\r
-(if it were set, the pattern would be anchored),\r
-\r
--1 is returned, indicating that the pattern matches only at the start of a\r
-subject string or after any "\\n" within the string. Otherwise -2 is returned.\r
-For anchored patterns, -2 is returned.\r
-\r
-  PCRE_INFO_FIRSTTABLE\r
-\r
-If the pattern was studied, and this resulted in the construction of a 256-bit\r
-table indicating a fixed set of characters for the first character in any\r
-matching string, a pointer to the table is returned. Otherwise NULL is\r
-returned. The fourth argument should point to an \fBunsigned char *\fR\r
-variable.\r
-\r
-  PCRE_INFO_LASTLITERAL\r
-\r
-For a non-anchored pattern, return the value of the rightmost literal character\r
-which must exist in any matched string, other than at its start. The fourth\r
-argument should point to an \fBint\fR variable. If there is no such character,\r
-or if the pattern is anchored, -1 is returned. For example, for the pattern\r
-/a\\d+z\\d+/ the returned value is 'z'.\r
-\r
-The \fBpcre_info()\fR function is now obsolete because its interface is too\r
-restrictive to return all the available data about a compiled pattern. New\r
-programs should use \fBpcre_fullinfo()\fR instead. The yield of\r
-\fBpcre_info()\fR is the number of capturing subpatterns, or one of the\r
-following negative numbers:\r
-\r
-  PCRE_ERROR_NULL       the argument \fIcode\fR was NULL\r
-  PCRE_ERROR_BADMAGIC   the "magic number" was not found\r
-\r
-If the \fIoptptr\fR argument is not NULL, a copy of the options with which the\r
-pattern was compiled is placed in the integer it points to (see\r
-PCRE_INFO_OPTIONS above).\r
-\r
-If the pattern is not anchored and the \fIfirstcharptr\fR argument is not NULL,\r
-it is used to pass back information about the first character of any matched\r
-string (see PCRE_INFO_FIRSTCHAR above).\r
-\r
-\r
-.SH MATCHING A PATTERN\r
-The function \fBpcre_exec()\fR is called to match a subject string against a\r
-pre-compiled pattern, which is passed in the \fIcode\fR argument. If the\r
-pattern has been studied, the result of the study should be passed in the\r
-\fIextra\fR argument. Otherwise this must be NULL.\r
-\r
-The PCRE_ANCHORED option can be passed in the \fIoptions\fR argument, whose\r
-unused bits must be zero. However, if a pattern was compiled with\r
-PCRE_ANCHORED, or turned out to be anchored by virtue of its contents, it\r
-cannot be made unachored at matching time.\r
-\r
-There are also three further options that can be set only at matching time:\r
-\r
-  PCRE_NOTBOL\r
-\r
-The first character of the string is not the beginning of a line, so the\r
-circumflex metacharacter should not match before it. Setting this without\r
-PCRE_MULTILINE (at compile time) causes circumflex never to match.\r
-\r
-  PCRE_NOTEOL\r
-\r
-The end of the string is not the end of a line, so the dollar metacharacter\r
-should not match it nor (except in multiline mode) a newline immediately before\r
-it. Setting this without PCRE_MULTILINE (at compile time) causes dollar never\r
-to match.\r
-\r
-  PCRE_NOTEMPTY\r
-\r
-An empty string is not considered to be a valid match if this option is set. If\r
-there are alternatives in the pattern, they are tried. If all the alternatives\r
-match the empty string, the entire match fails. For example, if the pattern\r
-\r
-  a?b?\r
-\r
-is applied to a string not beginning with "a" or "b", it matches the empty\r
-string at the start of the subject. With PCRE_NOTEMPTY set, this match is not\r
-valid, so PCRE searches further into the string for occurrences of "a" or "b".\r
-\r
-Perl has no direct equivalent of PCRE_NOTEMPTY, but it does make a special case\r
-of a pattern match of the empty string within its \fBsplit()\fR function, and\r
-when using the /g modifier. It is possible to emulate Perl's behaviour after\r
-matching a null string by first trying the match again at the same offset with\r
-PCRE_NOTEMPTY set, and then if that fails by advancing the starting offset (see\r
-below) and trying an ordinary match again.\r
-\r
-The subject string is passed as a pointer in \fIsubject\fR, a length in\r
-\fIlength\fR, and a starting offset in \fIstartoffset\fR. Unlike the pattern\r
-string, it may contain binary zero characters. When the starting offset is\r
-zero, the search for a match starts at the beginning of the subject, and this\r
-is by far the most common case.\r
-\r
-A non-zero starting offset is useful when searching for another match in the\r
-same subject by calling \fBpcre_exec()\fR again after a previous success.\r
-Setting \fIstartoffset\fR differs from just passing over a shortened string and\r
-setting PCRE_NOTBOL in the case of a pattern that begins with any kind of\r
-lookbehind. For example, consider the pattern\r
-\r
-  \\Biss\\B\r
-\r
-which finds occurrences of "iss" in the middle of words. (\\B matches only if\r
-the current position in the subject is not a word boundary.) When applied to\r
-the string "Mississipi" the first call to \fBpcre_exec()\fR finds the first\r
-occurrence. If \fBpcre_exec()\fR is called again with just the remainder of the\r
-subject, namely "issipi", it does not match, because \\B is always false at the\r
-start of the subject, which is deemed to be a word boundary. However, if\r
-\fBpcre_exec()\fR is passed the entire string again, but with \fIstartoffset\fR\r
-set to 4, it finds the second occurrence of "iss" because it is able to look\r
-behind the starting point to discover that it is preceded by a letter.\r
-\r
-If a non-zero starting offset is passed when the pattern is anchored, one\r
-attempt to match at the given offset is tried. This can only succeed if the\r
-pattern does not require the match to be at the start of the subject.\r
-\r
-In general, a pattern matches a certain portion of the subject, and in\r
-addition, further substrings from the subject may be picked out by parts of the\r
-pattern. Following the usage in Jeffrey Friedl's book, this is called\r
-"capturing" in what follows, and the phrase "capturing subpattern" is used for\r
-a fragment of a pattern that picks out a substring. PCRE supports several other\r
-kinds of parenthesized subpattern that do not cause substrings to be captured.\r
-\r
-Captured substrings are returned to the caller via a vector of integer offsets\r
-whose address is passed in \fIovector\fR. The number of elements in the vector\r
-is passed in \fIovecsize\fR. The first two-thirds of the vector is used to pass\r
-back captured substrings, each substring using a pair of integers. The\r
-remaining third of the vector is used as workspace by \fBpcre_exec()\fR while\r
-matching capturing subpatterns, and is not available for passing back\r
-information. The length passed in \fIovecsize\fR should always be a multiple of\r
-three. If it is not, it is rounded down.\r
-\r
-When a match has been successful, information about captured substrings is\r
-returned in pairs of integers, starting at the beginning of \fIovector\fR, and\r
-continuing up to two-thirds of its length at the most. The first element of a\r
-pair is set to the offset of the first character in a substring, and the second\r
-is set to the offset of the first character after the end of a substring. The\r
-first pair, \fIovector[0]\fR and \fIovector[1]\fR, identify the portion of the\r
-subject string matched by the entire pattern. The next pair is used for the\r
-first capturing subpattern, and so on. The value returned by \fBpcre_exec()\fR\r
-is the number of pairs that have been set. If there are no capturing\r
-subpatterns, the return value from a successful match is 1, indicating that\r
-just the first pair of offsets has been set.\r
-\r
-Some convenience functions are provided for extracting the captured substrings\r
-as separate strings. These are described in the following section.\r
-\r
-It is possible for an capturing subpattern number \fIn+1\fR to match some\r
-part of the subject when subpattern \fIn\fR has not been used at all. For\r
-example, if the string "abc" is matched against the pattern (a|(z))(bc)\r
-subpatterns 1 and 3 are matched, but 2 is not. When this happens, both offset\r
-values corresponding to the unused subpattern are set to -1.\r
-\r
-If a capturing subpattern is matched repeatedly, it is the last portion of the\r
-string that it matched that gets returned.\r
-\r
-If the vector is too small to hold all the captured substrings, it is used as\r
-far as possible (up to two-thirds of its length), and the function returns a\r
-value of zero. In particular, if the substring offsets are not of interest,\r
-\fBpcre_exec()\fR may be called with \fIovector\fR passed as NULL and\r
-\fIovecsize\fR as zero. However, if the pattern contains back references and\r
-the \fIovector\fR isn't big enough to remember the related substrings, PCRE has\r
-to get additional memory for use during matching. Thus it is usually advisable\r
-to supply an \fIovector\fR.\r
-\r
-Note that \fBpcre_info()\fR can be used to find out how many capturing\r
-subpatterns there are in a compiled pattern. The smallest size for\r
-\fIovector\fR that will allow for \fIn\fR captured substrings in addition to\r
-the offsets of the substring matched by the whole pattern is (\fIn\fR+1)*3.\r
-\r
-If \fBpcre_exec()\fR fails, it returns a negative number. The following are\r
-defined in the header file:\r
-\r
-  PCRE_ERROR_NOMATCH        (-1)\r
-\r
-The subject string did not match the pattern.\r
-\r
-  PCRE_ERROR_NULL           (-2)\r
-\r
-Either \fIcode\fR or \fIsubject\fR was passed as NULL, or \fIovector\fR was\r
-NULL and \fIovecsize\fR was not zero.\r
-\r
-  PCRE_ERROR_BADOPTION      (-3)\r
-\r
-An unrecognized bit was set in the \fIoptions\fR argument.\r
-\r
-  PCRE_ERROR_BADMAGIC       (-4)\r
-\r
-PCRE stores a 4-byte "magic number" at the start of the compiled code, to catch\r
-the case when it is passed a junk pointer. This is the error it gives when the\r
-magic number isn't present.\r
-\r
-  PCRE_ERROR_UNKNOWN_NODE   (-5)\r
-\r
-While running the pattern match, an unknown item was encountered in the\r
-compiled pattern. This error could be caused by a bug in PCRE or by overwriting\r
-of the compiled pattern.\r
-\r
-  PCRE_ERROR_NOMEMORY       (-6)\r
-\r
-If a pattern contains back references, but the \fIovector\fR that is passed to\r
-\fBpcre_exec()\fR is not big enough to remember the referenced substrings, PCRE\r
-gets a block of memory at the start of matching to use for this purpose. If the\r
-call via \fBpcre_malloc()\fR fails, this error is given. The memory is freed at\r
-the end of matching.\r
-\r
-\r
-.SH EXTRACTING CAPTURED SUBSTRINGS\r
-Captured substrings can be accessed directly by using the offsets returned by\r
-\fBpcre_exec()\fR in \fIovector\fR. For convenience, the functions\r
-\fBpcre_copy_substring()\fR, \fBpcre_get_substring()\fR, and\r
-\fBpcre_get_substring_list()\fR are provided for extracting captured substrings\r
-as new, separate, zero-terminated strings. A substring that contains a binary\r
-zero is correctly extracted and has a further zero added on the end, but the\r
-result does not, of course, function as a C string.\r
-\r
-The first three arguments are the same for all three functions: \fIsubject\fR\r
-is the subject string which has just been successfully matched, \fIovector\fR\r
-is a pointer to the vector of integer offsets that was passed to\r
-\fBpcre_exec()\fR, and \fIstringcount\fR is the number of substrings that\r
-were captured by the match, including the substring that matched the entire\r
-regular expression. This is the value returned by \fBpcre_exec\fR if it\r
-is greater than zero. If \fBpcre_exec()\fR returned zero, indicating that it\r
-ran out of space in \fIovector\fR, the value passed as \fIstringcount\fR should\r
-be the size of the vector divided by three.\r
-\r
-The functions \fBpcre_copy_substring()\fR and \fBpcre_get_substring()\fR\r
-extract a single substring, whose number is given as \fIstringnumber\fR. A\r
-value of zero extracts the substring that matched the entire pattern, while\r
-higher values extract the captured substrings. For \fBpcre_copy_substring()\fR,\r
-the string is placed in \fIbuffer\fR, whose length is given by\r
-\fIbuffersize\fR, while for \fBpcre_get_substring()\fR a new block of memory is\r
-obtained via \fBpcre_malloc\fR, and its address is returned via\r
-\fIstringptr\fR. The yield of the function is the length of the string, not\r
-including the terminating zero, or one of\r
-\r
-  PCRE_ERROR_NOMEMORY       (-6)\r
-\r
-The buffer was too small for \fBpcre_copy_substring()\fR, or the attempt to get\r
-memory failed for \fBpcre_get_substring()\fR.\r
-\r
-  PCRE_ERROR_NOSUBSTRING    (-7)\r
-\r
-There is no substring whose number is \fIstringnumber\fR.\r
-\r
-The \fBpcre_get_substring_list()\fR function extracts all available substrings\r
-and builds a list of pointers to them. All this is done in a single block of\r
-memory which is obtained via \fBpcre_malloc\fR. The address of the memory block\r
-is returned via \fIlistptr\fR, which is also the start of the list of string\r
-pointers. The end of the list is marked by a NULL pointer. The yield of the\r
-function is zero if all went well, or\r
-\r
-  PCRE_ERROR_NOMEMORY       (-6)\r
-\r
-if the attempt to get the memory block failed.\r
-\r
-When any of these functions encounter a substring that is unset, which can\r
-happen when capturing subpattern number \fIn+1\fR matches some part of the\r
-subject, but subpattern \fIn\fR has not been used at all, they return an empty\r
-string. This can be distinguished from a genuine zero-length substring by\r
-inspecting the appropriate offset in \fIovector\fR, which is negative for unset\r
-substrings.\r
-\r
-The two convenience functions \fBpcre_free_substring()\fR and\r
-\fBpcre_free_substring_list()\fR can be used to free the memory returned by\r
-a previous call of \fBpcre_get_substring()\fR or\r
-\fBpcre_get_substring_list()\fR, respectively. They do nothing more than call\r
-the function pointed to by \fBpcre_free\fR, which of course could be called\r
-directly from a C program. However, PCRE is used in some situations where it is\r
-linked via a special interface to another programming language which cannot use\r
-\fBpcre_free\fR directly; it is for these cases that the functions are\r
-provided.\r
-\r
-\r
-.SH LIMITATIONS\r
-There are some size limitations in PCRE but it is hoped that they will never in\r
-practice be relevant.\r
-The maximum length of a compiled pattern is 65539 (sic) bytes.\r
-All values in repeating quantifiers must be less than 65536.\r
-The maximum number of capturing subpatterns is 99.\r
-The maximum number of all parenthesized subpatterns, including capturing\r
-subpatterns, assertions, and other types of subpattern, is 200.\r
-\r
-The maximum length of a subject string is the largest positive number that an\r
-integer variable can hold. However, PCRE uses recursion to handle subpatterns\r
-and indefinite repetition. This means that the available stack space may limit\r
-the size of a subject string that can be processed by certain patterns.\r
-\r
-\r
-.SH DIFFERENCES FROM PERL\r
-The differences described here are with respect to Perl 5.005.\r
-\r
-1. By default, a whitespace character is any character that the C library\r
-function \fBisspace()\fR recognizes, though it is possible to compile PCRE with\r
-alternative character type tables. Normally \fBisspace()\fR matches space,\r
-formfeed, newline, carriage return, horizontal tab, and vertical tab. Perl 5\r
-no longer includes vertical tab in its set of whitespace characters. The \\v\r
-escape that was in the Perl documentation for a long time was never in fact\r
-recognized. However, the character itself was treated as whitespace at least\r
-up to 5.002. In 5.004 and 5.005 it does not match \\s.\r
-\r
-2. PCRE does not allow repeat quantifiers on lookahead assertions. Perl permits\r
-them, but they do not mean what you might think. For example, (?!a){3} does\r
-not assert that the next three characters are not "a". It just asserts that the\r
-next character is not "a" three times.\r
-\r
-3. Capturing subpatterns that occur inside negative lookahead assertions are\r
-counted, but their entries in the offsets vector are never set. Perl sets its\r
-numerical variables from any such patterns that are matched before the\r
-assertion fails to match something (thereby succeeding), but only if the\r
-negative lookahead assertion contains just one branch.\r
-\r
-4. Though binary zero characters are supported in the subject string, they are\r
-not allowed in a pattern string because it is passed as a normal C string,\r
-terminated by zero. The escape sequence "\\0" can be used in the pattern to\r
-represent a binary zero.\r
-\r
-5. The following Perl escape sequences are not supported: \\l, \\u, \\L, \\U,\r
-\\E, \\Q. In fact these are implemented by Perl's general string-handling and\r
-are not part of its pattern matching engine.\r
-\r
-6. The Perl \\G assertion is not supported as it is not relevant to single\r
-pattern matches.\r
-\r
-7. Fairly obviously, PCRE does not support the (?{code}) and (?p{code})\r
-constructions. However, there is some experimental support for recursive\r
-patterns using the non-Perl item (?R).\r
-\r
-8. There are at the time of writing some oddities in Perl 5.005_02 concerned\r
-with the settings of captured strings when part of a pattern is repeated. For\r
-example, matching "aba" against the pattern /^(a(b)?)+$/ sets $2 to the value\r
-"b", but matching "aabbaa" against /^(aa(bb)?)+$/ leaves $2 unset. However, if\r
-the pattern is changed to /^(aa(b(b))?)+$/ then $2 (and $3) are set.\r
-\r
-In Perl 5.004 $2 is set in both cases, and that is also true of PCRE. If in the\r
-future Perl changes to a consistent state that is different, PCRE may change to\r
-follow.\r
-\r
-9. Another as yet unresolved discrepancy is that in Perl 5.005_02 the pattern\r
-/^(a)?(?(1)a|b)+$/ matches the string "a", whereas in PCRE it does not.\r
-However, in both Perl and PCRE /^(a)?a/ matched against "a" leaves $1 unset.\r
-\r
-10. PCRE provides some extensions to the Perl regular expression facilities:\r
-\r
-(a) Although lookbehind assertions must match fixed length strings, each\r
-alternative branch of a lookbehind assertion can match a different length of\r
-string. Perl 5.005 requires them all to have the same length.\r
-\r
-(b) If PCRE_DOLLAR_ENDONLY is set and PCRE_MULTILINE is not set, the $ meta-\r
-character matches only at the very end of the string.\r
-\r
-(c) If PCRE_EXTRA is set, a backslash followed by a letter with no special\r
-meaning is faulted.\r
-\r
-(d) If PCRE_UNGREEDY is set, the greediness of the repetition quantifiers is\r
-inverted, that is, by default they are not greedy, but if followed by a\r
-question mark they are.\r
-\r
-(e) PCRE_ANCHORED can be used to force a pattern to be tried only at the start\r
-of the subject.\r
-\r
-(f) The PCRE_NOTBOL, PCRE_NOTEOL, and PCRE_NOTEMPTY options for\r
-\fBpcre_exec()\fR have no Perl equivalents.\r
-\r
-(g) The (?R) construct allows for recursive pattern matching (Perl 5.6 can do\r
-this using the (?p{code}) construct, which PCRE cannot of course support.)\r
-\r
-\r
-.SH REGULAR EXPRESSION DETAILS\r
-The syntax and semantics of the regular expressions supported by PCRE are\r
-described below. Regular expressions are also described in the Perl\r
-documentation and in a number of other books, some of which have copious\r
-examples. Jeffrey Friedl's "Mastering Regular Expressions", published by\r
-O'Reilly (ISBN 1-56592-257), covers them in great detail.\r
-\r
-The description here is intended as reference documentation. The basic\r
-operation of PCRE is on strings of bytes. However, there is the beginnings of\r
-some support for UTF-8 character strings. To use this support you must\r
-configure PCRE to include it, and then call \fBpcre_compile()\fR with the\r
-PCRE_UTF8 option. How this affects the pattern matching is described in the\r
-final section of this document.\r
-\r
-A regular expression is a pattern that is matched against a subject string from\r
-left to right. Most characters stand for themselves in a pattern, and match the\r
-corresponding characters in the subject. As a trivial example, the pattern\r
-\r
-  The quick brown fox\r
-\r
-matches a portion of a subject string that is identical to itself. The power of\r
-regular expressions comes from the ability to include alternatives and\r
-repetitions in the pattern. These are encoded in the pattern by the use of\r
-\fImeta-characters\fR, which do not stand for themselves but instead are\r
-interpreted in some special way.\r
-\r
-There are two different sets of meta-characters: those that are recognized\r
-anywhere in the pattern except within square brackets, and those that are\r
-recognized in square brackets. Outside square brackets, the meta-characters are\r
-as follows:\r
-\r
-  \\      general escape character with several uses\r
-  ^      assert start of subject (or line, in multiline mode)\r
-  $      assert end of subject (or line, in multiline mode)\r
-  .      match any character except newline (by default)\r
-  [      start character class definition\r
-  |      start of alternative branch\r
-  (      start subpattern\r
-  )      end subpattern\r
-  ?      extends the meaning of (\r
-         also 0 or 1 quantifier\r
-         also quantifier minimizer\r
-  *      0 or more quantifier\r
-  +      1 or more quantifier\r
-  {      start min/max quantifier\r
-\r
-Part of a pattern that is in square brackets is called a "character class". In\r
-a character class the only meta-characters are:\r
-\r
-  \\      general escape character\r
-  ^      negate the class, but only if the first character\r
-  -      indicates character range\r
-  ]      terminates the character class\r
-\r
-The following sections describe the use of each of the meta-characters.\r
-\r
-\r
-.SH BACKSLASH\r
-The backslash character has several uses. Firstly, if it is followed by a\r
-non-alphameric character, it takes away any special meaning that character may\r
-have. This use of backslash as an escape character applies both inside and\r
-outside character classes.\r
-\r
-For example, if you want to match a "*" character, you write "\\*" in the\r
-pattern. This applies whether or not the following character would otherwise be\r
-interpreted as a meta-character, so it is always safe to precede a\r
-non-alphameric with "\\" to specify that it stands for itself. In particular,\r
-if you want to match a backslash, you write "\\\\".\r
-\r
-If a pattern is compiled with the PCRE_EXTENDED option, whitespace in the\r
-pattern (other than in a character class) and characters between a "#" outside\r
-a character class and the next newline character are ignored. An escaping\r
-backslash can be used to include a whitespace or "#" character as part of the\r
-pattern.\r
-\r
-A second use of backslash provides a way of encoding non-printing characters\r
-in patterns in a visible manner. There is no restriction on the appearance of\r
-non-printing characters, apart from the binary zero that terminates a pattern,\r
-but when a pattern is being prepared by text editing, it is usually easier to\r
-use one of the following escape sequences than the binary character it\r
-represents:\r
-\r
-  \\a     alarm, that is, the BEL character (hex 07)\r
-  \\cx    "control-x", where x is any character\r
-  \\e     escape (hex 1B)\r
-  \\f     formfeed (hex 0C)\r
-  \\n     newline (hex 0A)\r
-  \\r     carriage return (hex 0D)\r
-  \\t     tab (hex 09)\r
-  \\xhh   character with hex code hh\r
-  \\ddd   character with octal code ddd, or backreference\r
-\r
-The precise effect of "\\cx" is as follows: if "x" is a lower case letter, it\r
-is converted to upper case. Then bit 6 of the character (hex 40) is inverted.\r
-Thus "\\cz" becomes hex 1A, but "\\c{" becomes hex 3B, while "\\c;" becomes hex\r
-7B.\r
-\r
-After "\\x", up to two hexadecimal digits are read (letters can be in upper or\r
-lower case).\r
-\r
-After "\\0" up to two further octal digits are read. In both cases, if there\r
-are fewer than two digits, just those that are present are used. Thus the\r
-sequence "\\0\\x\\07" specifies two binary zeros followed by a BEL character.\r
-Make sure you supply two digits after the initial zero if the character that\r
-follows is itself an octal digit.\r
-\r
-The handling of a backslash followed by a digit other than 0 is complicated.\r
-Outside a character class, PCRE reads it and any following digits as a decimal\r
-number. If the number is less than 10, or if there have been at least that many\r
-previous capturing left parentheses in the expression, the entire sequence is\r
-taken as a \fIback reference\fR. A description of how this works is given\r
-later, following the discussion of parenthesized subpatterns.\r
-\r
-Inside a character class, or if the decimal number is greater than 9 and there\r
-have not been that many capturing subpatterns, PCRE re-reads up to three octal\r
-digits following the backslash, and generates a single byte from the least\r
-significant 8 bits of the value. Any subsequent digits stand for themselves.\r
-For example:\r
-\r
-  \\040   is another way of writing a space\r
-  \\40    is the same, provided there are fewer than 40\r
-            previous capturing subpatterns\r
-  \\7     is always a back reference\r
-  \\11    might be a back reference, or another way of\r
-            writing a tab\r
-  \\011   is always a tab\r
-  \\0113  is a tab followed by the character "3"\r
-  \\113   is the character with octal code 113 (since there\r
-            can be no more than 99 back references)\r
-  \\377   is a byte consisting entirely of 1 bits\r
-  \\81    is either a back reference, or a binary zero\r
-            followed by the two characters "8" and "1"\r
-\r
-Note that octal values of 100 or greater must not be introduced by a leading\r
-zero, because no more than three octal digits are ever read.\r
-\r
-All the sequences that define a single byte value can be used both inside and\r
-outside character classes. In addition, inside a character class, the sequence\r
-"\\b" is interpreted as the backspace character (hex 08). Outside a character\r
-class it has a different meaning (see below).\r
-\r
-The third use of backslash is for specifying generic character types:\r
-\r
-  \\d     any decimal digit\r
-  \\D     any character that is not a decimal digit\r
-  \\s     any whitespace character\r
-  \\S     any character that is not a whitespace character\r
-  \\w     any "word" character\r
-  \\W     any "non-word" character\r
-\r
-Each pair of escape sequences partitions the complete set of characters into\r
-two disjoint sets. Any given character matches one, and only one, of each pair.\r
-\r
-A "word" character is any letter or digit or the underscore character, that is,\r
-any character which can be part of a Perl "word". The definition of letters and\r
-digits is controlled by PCRE's character tables, and may vary if locale-\r
-specific matching is taking place (see "Locale support" above). For example, in\r
-the "fr" (French) locale, some character codes greater than 128 are used for\r
-accented letters, and these are matched by \\w.\r
-\r
-These character type sequences can appear both inside and outside character\r
-classes. They each match one character of the appropriate type. If the current\r
-matching point is at the end of the subject string, all of them fail, since\r
-there is no character to match.\r
-\r
-The fourth use of backslash is for certain simple assertions. An assertion\r
-specifies a condition that has to be met at a particular point in a match,\r
-without consuming any characters from the subject string. The use of\r
-subpatterns for more complicated assertions is described below. The backslashed\r
-assertions are\r
-\r
-  \\b     word boundary\r
-  \\B     not a word boundary\r
-  \\A     start of subject (independent of multiline mode)\r
-  \\Z     end of subject or newline at end (independent of multiline mode)\r
-  \\z     end of subject (independent of multiline mode)\r
-\r
-These assertions may not appear in character classes (but note that "\\b" has a\r
-different meaning, namely the backspace character, inside a character class).\r
-\r
-A word boundary is a position in the subject string where the current character\r
-and the previous character do not both match \\w or \\W (i.e. one matches\r
-\\w and the other matches \\W), or the start or end of the string if the\r
-first or last character matches \\w, respectively.\r
-\r
-The \\A, \\Z, and \\z assertions differ from the traditional circumflex and\r
-dollar (described below) in that they only ever match at the very start and end\r
-of the subject string, whatever options are set. They are not affected by the\r
-PCRE_NOTBOL or PCRE_NOTEOL options. If the \fIstartoffset\fR argument of\r
-\fBpcre_exec()\fR is non-zero, \\A can never match. The difference between \\Z\r
-and \\z is that \\Z matches before a newline that is the last character of the\r
-string as well as at the end of the string, whereas \\z matches only at the\r
-end.\r
-\r
-\r
-.SH CIRCUMFLEX AND DOLLAR\r
-Outside a character class, in the default matching mode, the circumflex\r
-character is an assertion which is true only if the current matching point is\r
-at the start of the subject string. If the \fIstartoffset\fR argument of\r
-\fBpcre_exec()\fR is non-zero, circumflex can never match. Inside a character\r
-class, circumflex has an entirely different meaning (see below).\r
-\r
-Circumflex need not be the first character of the pattern if a number of\r
-alternatives are involved, but it should be the first thing in each alternative\r
-in which it appears if the pattern is ever to match that branch. If all\r
-possible alternatives start with a circumflex, that is, if the pattern is\r
-constrained to match only at the start of the subject, it is said to be an\r
-"anchored" pattern. (There are also other constructs that can cause a pattern\r
-to be anchored.)\r
-\r
-A dollar character is an assertion which is true only if the current matching\r
-point is at the end of the subject string, or immediately before a newline\r
-character that is the last character in the string (by default). Dollar need\r
-not be the last character of the pattern if a number of alternatives are\r
-involved, but it should be the last item in any branch in which it appears.\r
-Dollar has no special meaning in a character class.\r
-\r
-The meaning of dollar can be changed so that it matches only at the very end of\r
-the string, by setting the PCRE_DOLLAR_ENDONLY option at compile or matching\r
-time. This does not affect the \\Z assertion.\r
-\r
-The meanings of the circumflex and dollar characters are changed if the\r
-PCRE_MULTILINE option is set. When this is the case, they match immediately\r
-after and immediately before an internal "\\n" character, respectively, in\r
-addition to matching at the start and end of the subject string. For example,\r
-the pattern /^abc$/ matches the subject string "def\\nabc" in multiline mode,\r
-but not otherwise. Consequently, patterns that are anchored in single line mode\r
-because all branches start with "^" are not anchored in multiline mode, and a\r
-match for circumflex is possible when the \fIstartoffset\fR argument of\r
-\fBpcre_exec()\fR is non-zero. The PCRE_DOLLAR_ENDONLY option is ignored if\r
-PCRE_MULTILINE is set.\r
-\r
-Note that the sequences \\A, \\Z, and \\z can be used to match the start and\r
-end of the subject in both modes, and if all branches of a pattern start with\r
-\\A is it always anchored, whether PCRE_MULTILINE is set or not.\r
-\r
-\r
-.SH FULL STOP (PERIOD, DOT)\r
-Outside a character class, a dot in the pattern matches any one character in\r
-the subject, including a non-printing character, but not (by default) newline.\r
-If the PCRE_DOTALL option is set, dots match newlines as well. The handling of\r
-dot is entirely independent of the handling of circumflex and dollar, the only\r
-relationship being that they both involve newline characters. Dot has no\r
-special meaning in a character class.\r
-\r
-\r
-.SH SQUARE BRACKETS\r
-An opening square bracket introduces a character class, terminated by a closing\r
-square bracket. A closing square bracket on its own is not special. If a\r
-closing square bracket is required as a member of the class, it should be the\r
-first data character in the class (after an initial circumflex, if present) or\r
-escaped with a backslash.\r
-\r
-A character class matches a single character in the subject; the character must\r
-be in the set of characters defined by the class, unless the first character in\r
-the class is a circumflex, in which case the subject character must not be in\r
-the set defined by the class. If a circumflex is actually required as a member\r
-of the class, ensure it is not the first character, or escape it with a\r
-backslash.\r
-\r
-For example, the character class [aeiou] matches any lower case vowel, while\r
-[^aeiou] matches any character that is not a lower case vowel. Note that a\r
-circumflex is just a convenient notation for specifying the characters which\r
-are in the class by enumerating those that are not. It is not an assertion: it\r
-still consumes a character from the subject string, and fails if the current\r
-pointer is at the end of the string.\r
-\r
-When caseless matching is set, any letters in a class represent both their\r
-upper case and lower case versions, so for example, a caseless [aeiou] matches\r
-"A" as well as "a", and a caseless [^aeiou] does not match "A", whereas a\r
-caseful version would.\r
-\r
-The newline character is never treated in any special way in character classes,\r
-whatever the setting of the PCRE_DOTALL or PCRE_MULTILINE options is. A class\r
-such as [^a] will always match a newline.\r
-\r
-The minus (hyphen) character can be used to specify a range of characters in a\r
-character class. For example, [d-m] matches any letter between d and m,\r
-inclusive. If a minus character is required in a class, it must be escaped with\r
-a backslash or appear in a position where it cannot be interpreted as\r
-indicating a range, typically as the first or last character in the class.\r
-\r
-It is not possible to have the literal character "]" as the end character of a\r
-range. A pattern such as [W-]46] is interpreted as a class of two characters\r
-("W" and "-") followed by a literal string "46]", so it would match "W46]" or\r
-"-46]". However, if the "]" is escaped with a backslash it is interpreted as\r
-the end of range, so [W-\\]46] is interpreted as a single class containing a\r
-range followed by two separate characters. The octal or hexadecimal\r
-representation of "]" can also be used to end a range.\r
-\r
-Ranges operate in ASCII collating sequence. They can also be used for\r
-characters specified numerically, for example [\\000-\\037]. If a range that\r
-includes letters is used when caseless matching is set, it matches the letters\r
-in either case. For example, [W-c] is equivalent to [][\\^_`wxyzabc], matched\r
-caselessly, and if character tables for the "fr" locale are in use,\r
-[\\xc8-\\xcb] matches accented E characters in both cases.\r
-\r
-The character types \\d, \\D, \\s, \\S, \\w, and \\W may also appear in a\r
-character class, and add the characters that they match to the class. For\r
-example, [\\dABCDEF] matches any hexadecimal digit. A circumflex can\r
-conveniently be used with the upper case character types to specify a more\r
-restricted set of characters than the matching lower case type. For example,\r
-the class [^\\W_] matches any letter or digit, but not underscore.\r
-\r
-All non-alphameric characters other than \\, -, ^ (at the start) and the\r
-terminating ] are non-special in character classes, but it does no harm if they\r
-are escaped.\r
-\r
-\r
-.SH POSIX CHARACTER CLASSES\r
-Perl 5.6 (not yet released at the time of writing) is going to support the\r
-POSIX notation for character classes, which uses names enclosed by [: and :]\r
-within the enclosing square brackets. PCRE supports this notation. For example,\r
-\r
-  [01[:alpha:]%]\r
-\r
-matches "0", "1", any alphabetic character, or "%". The supported class names\r
-are\r
-\r
-  alnum    letters and digits\r
-  alpha    letters\r
-  ascii    character codes 0 - 127\r
-  cntrl    control characters\r
-  digit    decimal digits (same as \\d)\r
-  graph    printing characters, excluding space\r
-  lower    lower case letters\r
-  print    printing characters, including space\r
-  punct    printing characters, excluding letters and digits\r
-  space    white space (same as \\s)\r
-  upper    upper case letters\r
-  word     "word" characters (same as \\w)\r
-  xdigit   hexadecimal digits\r
-\r
-The names "ascii" and "word" are Perl extensions. Another Perl extension is\r
-negation, which is indicated by a ^ character after the colon. For example,\r
-\r
-  [12[:^digit:]]\r
-\r
-matches "1", "2", or any non-digit. PCRE (and Perl) also recogize the POSIX\r
-syntax [.ch.] and [=ch=] where "ch" is a "collating element", but these are not\r
-supported, and an error is given if they are encountered.\r
-\r
-\r
-.SH VERTICAL BAR\r
-Vertical bar characters are used to separate alternative patterns. For example,\r
-the pattern\r
-\r
-  gilbert|sullivan\r
-\r
-matches either "gilbert" or "sullivan". Any number of alternatives may appear,\r
-and an empty alternative is permitted (matching the empty string).\r
-The matching process tries each alternative in turn, from left to right,\r
-and the first one that succeeds is used. If the alternatives are within a\r
-subpattern (defined below), "succeeds" means matching the rest of the main\r
-pattern as well as the alternative in the subpattern.\r
-\r
-\r
-.SH INTERNAL OPTION SETTING\r
-The settings of PCRE_CASELESS, PCRE_MULTILINE, PCRE_DOTALL, and PCRE_EXTENDED\r
-can be changed from within the pattern by a sequence of Perl option letters\r
-enclosed between "(?" and ")". The option letters are\r
-\r
-  i  for PCRE_CASELESS\r
-  m  for PCRE_MULTILINE\r
-  s  for PCRE_DOTALL\r
-  x  for PCRE_EXTENDED\r
-\r
-For example, (?im) sets caseless, multiline matching. It is also possible to\r
-unset these options by preceding the letter with a hyphen, and a combined\r
-setting and unsetting such as (?im-sx), which sets PCRE_CASELESS and\r
-PCRE_MULTILINE while unsetting PCRE_DOTALL and PCRE_EXTENDED, is also\r
-permitted. If a letter appears both before and after the hyphen, the option is\r
-unset.\r
-\r
-The scope of these option changes depends on where in the pattern the setting\r
-occurs. For settings that are outside any subpattern (defined below), the\r
-effect is the same as if the options were set or unset at the start of\r
-matching. The following patterns all behave in exactly the same way:\r
-\r
-  (?i)abc\r
-  a(?i)bc\r
-  ab(?i)c\r
-  abc(?i)\r
-\r
-which in turn is the same as compiling the pattern abc with PCRE_CASELESS set.\r
-In other words, such "top level" settings apply to the whole pattern (unless\r
-there are other changes inside subpatterns). If there is more than one setting\r
-of the same option at top level, the rightmost setting is used.\r
-\r
-If an option change occurs inside a subpattern, the effect is different. This\r
-is a change of behaviour in Perl 5.005. An option change inside a subpattern\r
-affects only that part of the subpattern that follows it, so\r
-\r
-  (a(?i)b)c\r
-\r
-matches abc and aBc and no other strings (assuming PCRE_CASELESS is not used).\r
-By this means, options can be made to have different settings in different\r
-parts of the pattern. Any changes made in one alternative do carry on\r
-into subsequent branches within the same subpattern. For example,\r
-\r
-  (a(?i)b|c)\r
-\r
-matches "ab", "aB", "c", and "C", even though when matching "C" the first\r
-branch is abandoned before the option setting. This is because the effects of\r
-option settings happen at compile time. There would be some very weird\r
-behaviour otherwise.\r
-\r
-The PCRE-specific options PCRE_UNGREEDY and PCRE_EXTRA can be changed in the\r
-same way as the Perl-compatible options by using the characters U and X\r
-respectively. The (?X) flag setting is special in that it must always occur\r
-earlier in the pattern than any of the additional features it turns on, even\r
-when it is at top level. It is best put at the start.\r
-\r
-\r
-.SH SUBPATTERNS\r
-Subpatterns are delimited by parentheses (round brackets), which can be nested.\r
-Marking part of a pattern as a subpattern does two things:\r
-\r
-1. It localizes a set of alternatives. For example, the pattern\r
-\r
-  cat(aract|erpillar|)\r
-\r
-matches one of the words "cat", "cataract", or "caterpillar". Without the\r
-parentheses, it would match "cataract", "erpillar" or the empty string.\r
-\r
-2. It sets up the subpattern as a capturing subpattern (as defined above).\r
-When the whole pattern matches, that portion of the subject string that matched\r
-the subpattern is passed back to the caller via the \fIovector\fR argument of\r
-\fBpcre_exec()\fR. Opening parentheses are counted from left to right (starting\r
-from 1) to obtain the numbers of the capturing subpatterns.\r
-\r
-For example, if the string "the red king" is matched against the pattern\r
-\r
-  the ((red|white) (king|queen))\r
-\r
-the captured substrings are "red king", "red", and "king", and are numbered 1,\r
-2, and 3.\r
-\r
-The fact that plain parentheses fulfil two functions is not always helpful.\r
-There are often times when a grouping subpattern is required without a\r
-capturing requirement. If an opening parenthesis is followed by "?:", the\r
-subpattern does not do any capturing, and is not counted when computing the\r
-number of any subsequent capturing subpatterns. For example, if the string "the\r
-white queen" is matched against the pattern\r
-\r
-  the ((?:red|white) (king|queen))\r
-\r
-the captured substrings are "white queen" and "queen", and are numbered 1 and\r
-2. The maximum number of captured substrings is 99, and the maximum number of\r
-all subpatterns, both capturing and non-capturing, is 200.\r
-\r
-As a convenient shorthand, if any option settings are required at the start of\r
-a non-capturing subpattern, the option letters may appear between the "?" and\r
-the ":". Thus the two patterns\r
-\r
-  (?i:saturday|sunday)\r
-  (?:(?i)saturday|sunday)\r
-\r
-match exactly the same set of strings. Because alternative branches are tried\r
-from left to right, and options are not reset until the end of the subpattern\r
-is reached, an option setting in one branch does affect subsequent branches, so\r
-the above patterns match "SUNDAY" as well as "Saturday".\r
-\r
-\r
-.SH REPETITION\r
-Repetition is specified by quantifiers, which can follow any of the following\r
-items:\r
-\r
-  a single character, possibly escaped\r
-  the . metacharacter\r
-  a character class\r
-  a back reference (see next section)\r
-  a parenthesized subpattern (unless it is an assertion - see below)\r
-\r
-The general repetition quantifier specifies a minimum and maximum number of\r
-permitted matches, by giving the two numbers in curly brackets (braces),\r
-separated by a comma. The numbers must be less than 65536, and the first must\r
-be less than or equal to the second. For example:\r
-\r
-  z{2,4}\r
-\r
-matches "zz", "zzz", or "zzzz". A closing brace on its own is not a special\r
-character. If the second number is omitted, but the comma is present, there is\r
-no upper limit; if the second number and the comma are both omitted, the\r
-quantifier specifies an exact number of required matches. Thus\r
-\r
-  [aeiou]{3,}\r
-\r
-matches at least 3 successive vowels, but may match many more, while\r
-\r
-  \\d{8}\r
-\r
-matches exactly 8 digits. An opening curly bracket that appears in a position\r
-where a quantifier is not allowed, or one that does not match the syntax of a\r
-quantifier, is taken as a literal character. For example, {,6} is not a\r
-quantifier, but a literal string of four characters.\r
-\r
-The quantifier {0} is permitted, causing the expression to behave as if the\r
-previous item and the quantifier were not present.\r
-\r
-For convenience (and historical compatibility) the three most common\r
-quantifiers have single-character abbreviations:\r
-\r
-  *    is equivalent to {0,}\r
-  +    is equivalent to {1,}\r
-  ?    is equivalent to {0,1}\r
-\r
-It is possible to construct infinite loops by following a subpattern that can\r
-match no characters with a quantifier that has no upper limit, for example:\r
-\r
-  (a?)*\r
-\r
-Earlier versions of Perl and PCRE used to give an error at compile time for\r
-such patterns. However, because there are cases where this can be useful, such\r
-patterns are now accepted, but if any repetition of the subpattern does in fact\r
-match no characters, the loop is forcibly broken.\r
-\r
-By default, the quantifiers are "greedy", that is, they match as much as\r
-possible (up to the maximum number of permitted times), without causing the\r
-rest of the pattern to fail. The classic example of where this gives problems\r
-is in trying to match comments in C programs. These appear between the\r
-sequences /* and */ and within the sequence, individual * and / characters may\r
-appear. An attempt to match C comments by applying the pattern\r
-\r
-  /\\*.*\\*/\r
-\r
-to the string\r
-\r
-  /* first command */  not comment  /* second comment */\r
-\r
-fails, because it matches the entire string owing to the greediness of the .*\r
-item.\r
-\r
-However, if a quantifier is followed by a question mark, it ceases to be\r
-greedy, and instead matches the minimum number of times possible, so the\r
-pattern\r
-\r
-  /\\*.*?\\*/\r
-\r
-does the right thing with the C comments. The meaning of the various\r
-quantifiers is not otherwise changed, just the preferred number of matches.\r
-Do not confuse this use of question mark with its use as a quantifier in its\r
-own right. Because it has two uses, it can sometimes appear doubled, as in\r
-\r
-  \\d??\\d\r
-\r
-which matches one digit by preference, but can match two if that is the only\r
-way the rest of the pattern matches.\r
-\r
-If the PCRE_UNGREEDY option is set (an option which is not available in Perl),\r
-the quantifiers are not greedy by default, but individual ones can be made\r
-greedy by following them with a question mark. In other words, it inverts the\r
-default behaviour.\r
-\r
-When a parenthesized subpattern is quantified with a minimum repeat count that\r
-is greater than 1 or with a limited maximum, more store is required for the\r
-compiled pattern, in proportion to the size of the minimum or maximum.\r
-\r
-If a pattern starts with .* or .{0,} and the PCRE_DOTALL option (equivalent\r
-to Perl's /s) is set, thus allowing the . to match newlines, the pattern is\r
-implicitly anchored, because whatever follows will be tried against every\r
-character position in the subject string, so there is no point in retrying the\r
-overall match at any position after the first. PCRE treats such a pattern as\r
-though it were preceded by \\A. In cases where it is known that the subject\r
-string contains no newlines, it is worth setting PCRE_DOTALL when the pattern\r
-begins with .* in order to obtain this optimization, or alternatively using ^\r
-to indicate anchoring explicitly.\r
-\r
-When a capturing subpattern is repeated, the value captured is the substring\r
-that matched the final iteration. For example, after\r
-\r
-  (tweedle[dume]{3}\\s*)+\r
-\r
-has matched "tweedledum tweedledee" the value of the captured substring is\r
-"tweedledee". However, if there are nested capturing subpatterns, the\r
-corresponding captured values may have been set in previous iterations. For\r
-example, after\r
-\r
-  /(a|(b))+/\r
-\r
-matches "aba" the value of the second captured substring is "b".\r
-\r
-\r
-.SH BACK REFERENCES\r
-Outside a character class, a backslash followed by a digit greater than 0 (and\r
-possibly further digits) is a back reference to a capturing subpattern earlier\r
-(i.e. to its left) in the pattern, provided there have been that many previous\r
-capturing left parentheses.\r
-\r
-However, if the decimal number following the backslash is less than 10, it is\r
-always taken as a back reference, and causes an error only if there are not\r
-that many capturing left parentheses in the entire pattern. In other words, the\r
-parentheses that are referenced need not be to the left of the reference for\r
-numbers less than 10. See the section entitled "Backslash" above for further\r
-details of the handling of digits following a backslash.\r
-\r
-A back reference matches whatever actually matched the capturing subpattern in\r
-the current subject string, rather than anything matching the subpattern\r
-itself. So the pattern\r
-\r
-  (sens|respons)e and \\1ibility\r
-\r
-matches "sense and sensibility" and "response and responsibility", but not\r
-"sense and responsibility". If caseful matching is in force at the time of the\r
-back reference, the case of letters is relevant. For example,\r
-\r
-  ((?i)rah)\\s+\\1\r
-\r
-matches "rah rah" and "RAH RAH", but not "RAH rah", even though the original\r
-capturing subpattern is matched caselessly.\r
-\r
-There may be more than one back reference to the same subpattern. If a\r
-subpattern has not actually been used in a particular match, any back\r
-references to it always fail. For example, the pattern\r
-\r
-  (a|(bc))\\2\r
-\r
-always fails if it starts to match "a" rather than "bc". Because there may be\r
-up to 99 back references, all digits following the backslash are taken\r
-as part of a potential back reference number. If the pattern continues with a\r
-digit character, some delimiter must be used to terminate the back reference.\r
-If the PCRE_EXTENDED option is set, this can be whitespace. Otherwise an empty\r
-comment can be used.\r
-\r
-A back reference that occurs inside the parentheses to which it refers fails\r
-when the subpattern is first used, so, for example, (a\\1) never matches.\r
-However, such references can be useful inside repeated subpatterns. For\r
-example, the pattern\r
-\r
-  (a|b\\1)+\r
-\r
-matches any number of "a"s and also "aba", "ababbaa" etc. At each iteration of\r
-the subpattern, the back reference matches the character string corresponding\r
-to the previous iteration. In order for this to work, the pattern must be such\r
-that the first iteration does not need to match the back reference. This can be\r
-done using alternation, as in the example above, or by a quantifier with a\r
-minimum of zero.\r
-\r
-\r
-.SH ASSERTIONS\r
-An assertion is a test on the characters following or preceding the current\r
-matching point that does not actually consume any characters. The simple\r
-assertions coded as \\b, \\B, \\A, \\Z, \\z, ^ and $ are described above. More\r
-complicated assertions are coded as subpatterns. There are two kinds: those\r
-that look ahead of the current position in the subject string, and those that\r
-look behind it.\r
-\r
-An assertion subpattern is matched in the normal way, except that it does not\r
-cause the current matching position to be changed. Lookahead assertions start\r
-with (?= for positive assertions and (?! for negative assertions. For example,\r
-\r
-  \\w+(?=;)\r
-\r
-matches a word followed by a semicolon, but does not include the semicolon in\r
-the match, and\r
-\r
-  foo(?!bar)\r
-\r
-matches any occurrence of "foo" that is not followed by "bar". Note that the\r
-apparently similar pattern\r
-\r
-  (?!foo)bar\r
-\r
-does not find an occurrence of "bar" that is preceded by something other than\r
-"foo"; it finds any occurrence of "bar" whatsoever, because the assertion\r
-(?!foo) is always true when the next three characters are "bar". A\r
-lookbehind assertion is needed to achieve this effect.\r
-\r
-Lookbehind assertions start with (?<= for positive assertions and (?<! for\r
-negative assertions. For example,\r
-\r
-  (?<!foo)bar\r
-\r
-does find an occurrence of "bar" that is not preceded by "foo". The contents of\r
-a lookbehind assertion are restricted such that all the strings it matches must\r
-have a fixed length. However, if there are several alternatives, they do not\r
-all have to have the same fixed length. Thus\r
-\r
-  (?<=bullock|donkey)\r
-\r
-is permitted, but\r
-\r
-  (?<!dogs?|cats?)\r
-\r
-causes an error at compile time. Branches that match different length strings\r
-are permitted only at the top level of a lookbehind assertion. This is an\r
-extension compared with Perl 5.005, which requires all branches to match the\r
-same length of string. An assertion such as\r
-\r
-  (?<=ab(c|de))\r
-\r
-is not permitted, because its single top-level branch can match two different\r
-lengths, but it is acceptable if rewritten to use two top-level branches:\r
-\r
-  (?<=abc|abde)\r
-\r
-The implementation of lookbehind assertions is, for each alternative, to\r
-temporarily move the current position back by the fixed width and then try to\r
-match. If there are insufficient characters before the current position, the\r
-match is deemed to fail. Lookbehinds in conjunction with once-only subpatterns\r
-can be particularly useful for matching at the ends of strings; an example is\r
-given at the end of the section on once-only subpatterns.\r
-\r
-Several assertions (of any sort) may occur in succession. For example,\r
-\r
-  (?<=\\d{3})(?<!999)foo\r
-\r
-matches "foo" preceded by three digits that are not "999". Notice that each of\r
-the assertions is applied independently at the same point in the subject\r
-string. First there is a check that the previous three characters are all\r
-digits, and then there is a check that the same three characters are not "999".\r
-This pattern does \fInot\fR match "foo" preceded by six characters, the first\r
-of which are digits and the last three of which are not "999". For example, it\r
-doesn't match "123abcfoo". A pattern to do that is\r
-\r
-  (?<=\\d{3}...)(?<!999)foo\r
-\r
-This time the first assertion looks at the preceding six characters, checking\r
-that the first three are digits, and then the second assertion checks that the\r
-preceding three characters are not "999".\r
-\r
-Assertions can be nested in any combination. For example,\r
-\r
-  (?<=(?<!foo)bar)baz\r
-\r
-matches an occurrence of "baz" that is preceded by "bar" which in turn is not\r
-preceded by "foo", while\r
-\r
-  (?<=\\d{3}(?!999)...)foo\r
-\r
-is another pattern which matches "foo" preceded by three digits and any three\r
-characters that are not "999".\r
-\r
-Assertion subpatterns are not capturing subpatterns, and may not be repeated,\r
-because it makes no sense to assert the same thing several times. If any kind\r
-of assertion contains capturing subpatterns within it, these are counted for\r
-the purposes of numbering the capturing subpatterns in the whole pattern.\r
-However, substring capturing is carried out only for positive assertions,\r
-because it does not make sense for negative assertions.\r
-\r
-Assertions count towards the maximum of 200 parenthesized subpatterns.\r
-\r
-\r
-.SH ONCE-ONLY SUBPATTERNS\r
-With both maximizing and minimizing repetition, failure of what follows\r
-normally causes the repeated item to be re-evaluated to see if a different\r
-number of repeats allows the rest of the pattern to match. Sometimes it is\r
-useful to prevent this, either to change the nature of the match, or to cause\r
-it fail earlier than it otherwise might, when the author of the pattern knows\r
-there is no point in carrying on.\r
-\r
-Consider, for example, the pattern \\d+foo when applied to the subject line\r
-\r
-  123456bar\r
-\r
-After matching all 6 digits and then failing to match "foo", the normal\r
-action of the matcher is to try again with only 5 digits matching the \\d+\r
-item, and then with 4, and so on, before ultimately failing. Once-only\r
-subpatterns provide the means for specifying that once a portion of the pattern\r
-has matched, it is not to be re-evaluated in this way, so the matcher would\r
-give up immediately on failing to match "foo" the first time. The notation is\r
-another kind of special parenthesis, starting with (?> as in this example:\r
-\r
-  (?>\\d+)bar\r
-\r
-This kind of parenthesis "locks up" the  part of the pattern it contains once\r
-it has matched, and a failure further into the pattern is prevented from\r
-backtracking into it. Backtracking past it to previous items, however, works as\r
-normal.\r
-\r
-An alternative description is that a subpattern of this type matches the string\r
-of characters that an identical standalone pattern would match, if anchored at\r
-the current point in the subject string.\r
-\r
-Once-only subpatterns are not capturing subpatterns. Simple cases such as the\r
-above example can be thought of as a maximizing repeat that must swallow\r
-everything it can. So, while both \\d+ and \\d+? are prepared to adjust the\r
-number of digits they match in order to make the rest of the pattern match,\r
-(?>\\d+) can only match an entire sequence of digits.\r
-\r
-This construction can of course contain arbitrarily complicated subpatterns,\r
-and it can be nested.\r
-\r
-Once-only subpatterns can be used in conjunction with lookbehind assertions to\r
-specify efficient matching at the end of the subject string. Consider a simple\r
-pattern such as\r
-\r
-  abcd$\r
-\r
-when applied to a long string which does not match. Because matching proceeds\r
-from left to right, PCRE will look for each "a" in the subject and then see if\r
-what follows matches the rest of the pattern. If the pattern is specified as\r
-\r
-  ^.*abcd$\r
-\r
-the initial .* matches the entire string at first, but when this fails (because\r
-there is no following "a"), it backtracks to match all but the last character,\r
-then all but the last two characters, and so on. Once again the search for "a"\r
-covers the entire string, from right to left, so we are no better off. However,\r
-if the pattern is written as\r
-\r
-  ^(?>.*)(?<=abcd)\r
-\r
-there can be no backtracking for the .* item; it can match only the entire\r
-string. The subsequent lookbehind assertion does a single test on the last four\r
-characters. If it fails, the match fails immediately. For long strings, this\r
-approach makes a significant difference to the processing time.\r
-\r
-When a pattern contains an unlimited repeat inside a subpattern that can itself\r
-be repeated an unlimited number of times, the use of a once-only subpattern is\r
-the only way to avoid some failing matches taking a very long time indeed.\r
-The pattern\r
-\r
-  (\\D+|<\\d+>)*[!?]\r
-\r
-matches an unlimited number of substrings that either consist of non-digits, or\r
-digits enclosed in <>, followed by either ! or ?. When it matches, it runs\r
-quickly. However, if it is applied to\r
-\r
-  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r
-\r
-it takes a long time before reporting failure. This is because the string can\r
-be divided between the two repeats in a large number of ways, and all have to\r
-be tried. (The example used [!?] rather than a single character at the end,\r
-because both PCRE and Perl have an optimization that allows for fast failure\r
-when a single character is used. They remember the last single character that\r
-is required for a match, and fail early if it is not present in the string.)\r
-If the pattern is changed to\r
-\r
-  ((?>\\D+)|<\\d+>)*[!?]\r
-\r
-sequences of non-digits cannot be broken, and failure happens quickly.\r
-\r
-\r
-.SH CONDITIONAL SUBPATTERNS\r
-It is possible to cause the matching process to obey a subpattern\r
-conditionally or to choose between two alternative subpatterns, depending on\r
-the result of an assertion, or whether a previous capturing subpattern matched\r
-or not. The two possible forms of conditional subpattern are\r
-\r
-  (?(condition)yes-pattern)\r
-  (?(condition)yes-pattern|no-pattern)\r
-\r
-If the condition is satisfied, the yes-pattern is used; otherwise the\r
-no-pattern (if present) is used. If there are more than two alternatives in the\r
-subpattern, a compile-time error occurs.\r
-\r
-There are two kinds of condition. If the text between the parentheses consists\r
-of a sequence of digits, the condition is satisfied if the capturing subpattern\r
-of that number has previously matched. The number must be greater than zero.\r
-Consider the following pattern, which contains non-significant white space to\r
-make it more readable (assume the PCRE_EXTENDED option) and to divide it into\r
-three parts for ease of discussion:\r
-\r
-  ( \\( )?    [^()]+    (?(1) \\) )\r
-\r
-The first part matches an optional opening parenthesis, and if that\r
-character is present, sets it as the first captured substring. The second part\r
-matches one or more characters that are not parentheses. The third part is a\r
-conditional subpattern that tests whether the first set of parentheses matched\r
-or not. If they did, that is, if subject started with an opening parenthesis,\r
-the condition is true, and so the yes-pattern is executed and a closing\r
-parenthesis is required. Otherwise, since no-pattern is not present, the\r
-subpattern matches nothing. In other words, this pattern matches a sequence of\r
-non-parentheses, optionally enclosed in parentheses.\r
-\r
-If the condition is not a sequence of digits, it must be an assertion. This may\r
-be a positive or negative lookahead or lookbehind assertion. Consider this\r
-pattern, again containing non-significant white space, and with the two\r
-alternatives on the second line:\r
-\r
-  (?(?=[^a-z]*[a-z])\r
-  \\d{2}-[a-z]{3}-\\d{2}  |  \\d{2}-\\d{2}-\\d{2} )\r
-\r
-The condition is a positive lookahead assertion that matches an optional\r
-sequence of non-letters followed by a letter. In other words, it tests for the\r
-presence of at least one letter in the subject. If a letter is found, the\r
-subject is matched against the first alternative; otherwise it is matched\r
-against the second. This pattern matches strings in one of the two forms\r
-dd-aaa-dd or dd-dd-dd, where aaa are letters and dd are digits.\r
-\r
-\r
-.SH COMMENTS\r
-The sequence (?# marks the start of a comment which continues up to the next\r
-closing parenthesis. Nested parentheses are not permitted. The characters\r
-that make up a comment play no part in the pattern matching at all.\r
-\r
-If the PCRE_EXTENDED option is set, an unescaped # character outside a\r
-character class introduces a comment that continues up to the next newline\r
-character in the pattern.\r
-\r
-\r
-.SH RECURSIVE PATTERNS\r
-Consider the problem of matching a string in parentheses, allowing for\r
-unlimited nested parentheses. Without the use of recursion, the best that can\r
-be done is to use a pattern that matches up to some fixed depth of nesting. It\r
-is not possible to handle an arbitrary nesting depth. Perl 5.6 has provided an\r
-experimental facility that allows regular expressions to recurse (amongst other\r
-things). It does this by interpolating Perl code in the expression at run time,\r
-and the code can refer to the expression itself. A Perl pattern to solve the\r
-parentheses problem can be created like this:\r
-\r
-  $re = qr{\\( (?: (?>[^()]+) | (?p{$re}) )* \\)}x;\r
-\r
-The (?p{...}) item interpolates Perl code at run time, and in this case refers\r
-recursively to the pattern in which it appears. Obviously, PCRE cannot support\r
-the interpolation of Perl code. Instead, the special item (?R) is provided for\r
-the specific case of recursion. This PCRE pattern solves the parentheses\r
-problem (assume the PCRE_EXTENDED option is set so that white space is\r
-ignored):\r
-\r
-  \\( ( (?>[^()]+) | (?R) )* \\)\r
-\r
-First it matches an opening parenthesis. Then it matches any number of\r
-substrings which can either be a sequence of non-parentheses, or a recursive\r
-match of the pattern itself (i.e. a correctly parenthesized substring). Finally\r
-there is a closing parenthesis.\r
-\r
-This particular example pattern contains nested unlimited repeats, and so the\r
-use of a once-only subpattern for matching strings of non-parentheses is\r
-important when applying the pattern to strings that do not match. For example,\r
-when it is applied to\r
-\r
-  (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa()\r
-\r
-it yields "no match" quickly. However, if a once-only subpattern is not used,\r
-the match runs for a very long time indeed because there are so many different\r
-ways the + and * repeats can carve up the subject, and all have to be tested\r
-before failure can be reported.\r
-\r
-The values set for any capturing subpatterns are those from the outermost level\r
-of the recursion at which the subpattern value is set. If the pattern above is\r
-matched against\r
-\r
-  (ab(cd)ef)\r
-\r
-the value for the capturing parentheses is "ef", which is the last value taken\r
-on at the top level. If additional parentheses are added, giving\r
-\r
-  \\( ( ( (?>[^()]+) | (?R) )* ) \\)\r
-     ^                        ^\r
-     ^                        ^\r
-the string they capture is "ab(cd)ef", the contents of the top level\r
-parentheses. If there are more than 15 capturing parentheses in a pattern, PCRE\r
-has to obtain extra memory to store data during a recursion, which it does by\r
-using \fBpcre_malloc\fR, freeing it via \fBpcre_free\fR afterwards. If no\r
-memory can be obtained, it saves data for the first 15 capturing parentheses\r
-only, as there is no way to give an out-of-memory error from within a\r
-recursion.\r
-\r
-\r
-.SH PERFORMANCE\r
-Certain items that may appear in patterns are more efficient than others. It is\r
-more efficient to use a character class like [aeiou] than a set of alternatives\r
-such as (a|e|i|o|u). In general, the simplest construction that provides the\r
-required behaviour is usually the most efficient. Jeffrey Friedl's book\r
-contains a lot of discussion about optimizing regular expressions for efficient\r
-performance.\r
-\r
-When a pattern begins with .* and the PCRE_DOTALL option is set, the pattern is\r
-implicitly anchored by PCRE, since it can match only at the start of a subject\r
-string. However, if PCRE_DOTALL is not set, PCRE cannot make this optimization,\r
-because the . metacharacter does not then match a newline, and if the subject\r
-string contains newlines, the pattern may match from the character immediately\r
-following one of them instead of from the very start. For example, the pattern\r
-\r
-  (.*) second\r
-\r
-matches the subject "first\\nand second" (where \\n stands for a newline\r
-character) with the first captured substring being "and". In order to do this,\r
-PCRE has to retry the match starting after every newline in the subject.\r
-\r
-If you are using such a pattern with subject strings that do not contain\r
-newlines, the best performance is obtained by setting PCRE_DOTALL, or starting\r
-the pattern with ^.* to indicate explicit anchoring. That saves PCRE from\r
-having to scan along the subject looking for a newline to restart at.\r
-\r
-Beware of patterns that contain nested indefinite repeats. These can take a\r
-long time to run when applied to a string that does not match. Consider the\r
-pattern fragment\r
-\r
-  (a+)*\r
-\r
-This can match "aaaa" in 33 different ways, and this number increases very\r
-rapidly as the string gets longer. (The * repeat can match 0, 1, 2, 3, or 4\r
-times, and for each of those cases other than 0, the + repeats can match\r
-different numbers of times.) When the remainder of the pattern is such that the\r
-entire match is going to fail, PCRE has in principle to try every possible\r
-variation, and this can take an extremely long time.\r
-\r
-An optimization catches some of the more simple cases such as\r
-\r
-  (a+)*b\r
-\r
-where a literal character follows. Before embarking on the standard matching\r
-procedure, PCRE checks that there is a "b" later in the subject string, and if\r
-there is not, it fails the match immediately. However, when there is no\r
-following literal this optimization cannot be used. You can see the difference\r
-by comparing the behaviour of\r
-\r
-  (a+)*\\d\r
-\r
-with the pattern above. The former gives a failure almost instantly when\r
-applied to a whole line of "a" characters, whereas the latter takes an\r
-appreciable time with strings longer than about 20 characters.\r
-\r
-\r
-.SH UTF-8 SUPPORT\r
-Starting at release 3.3, PCRE has some support for character strings encoded\r
-in the UTF-8 format. This is incomplete, and is regarded as experimental. In\r
-order to use it, you must configure PCRE to include UTF-8 support in the code,\r
-and, in addition, you must call \fBpcre_compile()\fR with the PCRE_UTF8 option\r
-flag. When you do this, both the pattern and any subject strings that are\r
-matched against it are treated as UTF-8 strings instead of just strings of\r
-bytes, but only in the cases that are mentioned below.\r
-\r
-If you compile PCRE with UTF-8 support, but do not use it at run time, the\r
-library will be a bit bigger, but the additional run time overhead is limited\r
-to testing the PCRE_UTF8 flag in several places, so should not be very large.\r
-\r
-PCRE assumes that the strings it is given contain valid UTF-8 codes. It does\r
-not diagnose invalid UTF-8 strings. If you pass invalid UTF-8 strings to PCRE,\r
-the results are undefined.\r
-\r
-Running with PCRE_UTF8 set causes these changes in the way PCRE works:\r
-\r
-1. In a pattern, the escape sequence \\x{...}, where the contents of the braces\r
-is a string of hexadecimal digits, is interpreted as a UTF-8 character whose\r
-code number is the given hexadecimal number, for example: \\x{1234}. This\r
-inserts from one to six literal bytes into the pattern, using the UTF-8\r
-encoding. If a non-hexadecimal digit appears between the braces, the item is\r
-not recognized.\r
-\r
-2. The original hexadecimal escape sequence, \\xhh, generates a two-byte UTF-8\r
-character if its value is greater than 127.\r
-\r
-3. Repeat quantifiers are NOT correctly handled if they follow a multibyte\r
-character. For example, \\x{100}* and \\xc3+ do not work. If you want to\r
-repeat such characters, you must enclose them in non-capturing parentheses,\r
-for example (?:\\x{100}), at present.\r
-\r
-4. The dot metacharacter matches one UTF-8 character instead of a single byte.\r
-\r
-5. Unlike literal UTF-8 characters, the dot metacharacter followed by a\r
-repeat quantifier does operate correctly on UTF-8 characters instead of\r
-single bytes.\r
-\r
-4. Although the \\x{...} escape is permitted in a character class, characters\r
-whose values are greater than 255 cannot be included in a class.\r
-\r
-5. A class is matched against a UTF-8 character instead of just a single byte,\r
-but it can match only characters whose values are less than 256. Characters\r
-with greater values always fail to match a class.\r
-\r
-6. Repeated classes work correctly on multiple characters.\r
-\r
-7. Classes containing just a single character whose value is greater than 127\r
-(but less than 256), for example, [\\x80] or [^\\x{93}], do not work because\r
-these are optimized into single byte matches. In the first case, of course,\r
-the class brackets are just redundant.\r
-\r
-8. Lookbehind assertions move backwards in the subject by a fixed number of\r
-characters instead of a fixed number of bytes. Simple cases have been tested\r
-to work correctly, but there may be hidden gotchas herein.\r
-\r
-9. The character types such as \\d and \\w do not work correctly with UTF-8\r
-characters. They continue to test a single byte.\r
-\r
-10. Anything not explicitly mentioned here continues to work in bytes rather\r
-than in characters.\r
-\r
-The following UTF-8 features of Perl 5.6 are not implemented:\r
-\r
-1. The escape sequence \\C to match a single byte.\r
-\r
-2. The use of Unicode tables and properties and escapes \\p, \\P, and \\X.\r
-\r
-.SH AUTHOR\r
-Philip Hazel <ph10@cam.ac.uk>\r
-.br\r
-University Computing Service,\r
-.br\r
-New Museums Site,\r
-.br\r
-Cambridge CB2 3QG, England.\r
-.br\r
-Phone: +44 1223 334714\r
-\r
-Last updated: 28 August 2000,\r
-.br\r
-  the 250th anniversary of the death of J.S. Bach.\r
-.br\r
-Copyright (c) 1997-2000 University of Cambridge.\r