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

Diff of /code/trunk/doc/pcreapi.3

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 65 by nigel, Sat Feb 24 21:40:08 2007 UTC revision 75 by nigel, Sat Feb 24 21:40:37 2007 UTC
# Line 1  Line 1 
1  .TH PCRE 3  .TH PCRE 3
2  .SH NAME  .SH NAME
3  PCRE - Perl-compatible regular expressions  PCRE - Perl-compatible regular expressions
4  .SH SYNOPSIS OF PCRE API  .SH "PCRE NATIVE API"
5  .rs  .rs
6  .sp  .sp
7  .B #include <pcre.h>  .B #include <pcre.h>
8  .PP  .PP
9  .SM  .SM
10  .br  .br
11  .B pcre *pcre_compile(const char *\fIpattern\fR, int \fIoptions\fR,  .B pcre *pcre_compile(const char *\fIpattern\fP, int \fIoptions\fP,
12  .ti +5n  .ti +5n
13  .B const char **\fIerrptr\fR, int *\fIerroffset\fR,  .B const char **\fIerrptr\fP, int *\fIerroffset\fP,
14  .ti +5n  .ti +5n
15  .B const unsigned char *\fItableptr\fR);  .B const unsigned char *\fItableptr\fP);
16  .PP  .PP
17  .br  .br
18  .B pcre_extra *pcre_study(const pcre *\fIcode\fR, int \fIoptions\fR,  .B pcre_extra *pcre_study(const pcre *\fIcode\fP, int \fIoptions\fP,
19  .ti +5n  .ti +5n
20  .B const char **\fIerrptr\fR);  .B const char **\fIerrptr\fP);
21  .PP  .PP
22  .br  .br
23  .B int pcre_exec(const pcre *\fIcode\fR, "const pcre_extra *\fIextra\fR,"  .B int pcre_exec(const pcre *\fIcode\fP, "const pcre_extra *\fIextra\fP,"
24  .ti +5n  .ti +5n
25  .B "const char *\fIsubject\fR," int \fIlength\fR, int \fIstartoffset\fR,  .B "const char *\fIsubject\fP," int \fIlength\fP, int \fIstartoffset\fP,
26  .ti +5n  .ti +5n
27  .B int \fIoptions\fR, int *\fIovector\fR, int \fIovecsize\fR);  .B int \fIoptions\fP, int *\fIovector\fP, int \fIovecsize\fP);
28  .PP  .PP
29  .br  .br
30  .B int pcre_copy_named_substring(const pcre *\fIcode\fR,  .B int pcre_copy_named_substring(const pcre *\fIcode\fP,
31  .ti +5n  .ti +5n
32  .B const char *\fIsubject\fR, int *\fIovector\fR,  .B const char *\fIsubject\fP, int *\fIovector\fP,
33  .ti +5n  .ti +5n
34  .B int \fIstringcount\fR, const char *\fIstringname\fR,  .B int \fIstringcount\fP, const char *\fIstringname\fP,
35  .ti +5n  .ti +5n
36  .B char *\fIbuffer\fR, int \fIbuffersize\fR);  .B char *\fIbuffer\fP, int \fIbuffersize\fP);
37  .PP  .PP
38  .br  .br
39  .B int pcre_copy_substring(const char *\fIsubject\fR, int *\fIovector\fR,  .B int pcre_copy_substring(const char *\fIsubject\fP, int *\fIovector\fP,
40  .ti +5n  .ti +5n
41  .B int \fIstringcount\fR, int \fIstringnumber\fR, char *\fIbuffer\fR,  .B int \fIstringcount\fP, int \fIstringnumber\fP, char *\fIbuffer\fP,
42  .ti +5n  .ti +5n
43  .B int \fIbuffersize\fR);  .B int \fIbuffersize\fP);
44  .PP  .PP
45  .br  .br
46  .B int pcre_get_named_substring(const pcre *\fIcode\fR,  .B int pcre_get_named_substring(const pcre *\fIcode\fP,
47  .ti +5n  .ti +5n
48  .B const char *\fIsubject\fR, int *\fIovector\fR,  .B const char *\fIsubject\fP, int *\fIovector\fP,
49  .ti +5n  .ti +5n
50  .B int \fIstringcount\fR, const char *\fIstringname\fR,  .B int \fIstringcount\fP, const char *\fIstringname\fP,
51  .ti +5n  .ti +5n
52  .B const char **\fIstringptr\fR);  .B const char **\fIstringptr\fP);
53  .PP  .PP
54  .br  .br
55  .B int pcre_get_stringnumber(const pcre *\fIcode\fR,  .B int pcre_get_stringnumber(const pcre *\fIcode\fP,
56  .ti +5n  .ti +5n
57  .B const char *\fIname\fR);  .B const char *\fIname\fP);
58  .PP  .PP
59  .br  .br
60  .B int pcre_get_substring(const char *\fIsubject\fR, int *\fIovector\fR,  .B int pcre_get_substring(const char *\fIsubject\fP, int *\fIovector\fP,
61  .ti +5n  .ti +5n
62  .B int \fIstringcount\fR, int \fIstringnumber\fR,  .B int \fIstringcount\fP, int \fIstringnumber\fP,
63  .ti +5n  .ti +5n
64  .B const char **\fIstringptr\fR);  .B const char **\fIstringptr\fP);
65  .PP  .PP
66  .br  .br
67  .B int pcre_get_substring_list(const char *\fIsubject\fR,  .B int pcre_get_substring_list(const char *\fIsubject\fP,
68  .ti +5n  .ti +5n
69  .B int *\fIovector\fR, int \fIstringcount\fR, "const char ***\fIlistptr\fR);"  .B int *\fIovector\fP, int \fIstringcount\fP, "const char ***\fIlistptr\fP);"
70  .PP  .PP
71  .br  .br
72  .B void pcre_free_substring(const char *\fIstringptr\fR);  .B void pcre_free_substring(const char *\fIstringptr\fP);
73  .PP  .PP
74  .br  .br
75  .B void pcre_free_substring_list(const char **\fIstringptr\fR);  .B void pcre_free_substring_list(const char **\fIstringptr\fP);
76  .PP  .PP
77  .br  .br
78  .B const unsigned char *pcre_maketables(void);  .B const unsigned char *pcre_maketables(void);
79  .PP  .PP
80  .br  .br
81  .B int pcre_fullinfo(const pcre *\fIcode\fR, "const pcre_extra *\fIextra\fR,"  .B int pcre_fullinfo(const pcre *\fIcode\fP, "const pcre_extra *\fIextra\fP,"
82  .ti +5n  .ti +5n
83  .B int \fIwhat\fR, void *\fIwhere\fR);  .B int \fIwhat\fP, void *\fIwhere\fP);
84  .PP  .PP
85  .br  .br
86  .B int pcre_info(const pcre *\fIcode\fR, int *\fIoptptr\fR, int  .B int pcre_info(const pcre *\fIcode\fP, int *\fIoptptr\fP, int
87  .B *\fIfirstcharptr\fR);  .B *\fIfirstcharptr\fP);
88  .PP  .PP
89  .br  .br
90  .B int pcre_config(int \fIwhat\fR, void *\fIwhere\fR);  .B int pcre_config(int \fIwhat\fP, void *\fIwhere\fP);
91  .PP  .PP
92  .br  .br
93  .B char *pcre_version(void);  .B char *pcre_version(void);
# Line 99  PCRE - Perl-compatible regular expressio Line 99  PCRE - Perl-compatible regular expressio
99  .B void (*pcre_free)(void *);  .B void (*pcre_free)(void *);
100  .PP  .PP
101  .br  .br
102    .B void *(*pcre_stack_malloc)(size_t);
103    .PP
104    .br
105    .B void (*pcre_stack_free)(void *);
106    .PP
107    .br
108  .B int (*pcre_callout)(pcre_callout_block *);  .B int (*pcre_callout)(pcre_callout_block *);
109    .
110  .SH PCRE API  .
111    .SH "PCRE API OVERVIEW"
112  .rs  .rs
113  .sp  .sp
114  PCRE has its own native API, which is described in this document. There is also  PCRE has its own native API, which is described in this document. There is also
115  a set of wrapper functions that correspond to the POSIX regular expression API.  a set of wrapper functions that correspond to the POSIX regular expression API.
116  These are described in the \fBpcreposix\fR documentation.  These are described in the
117    .\" HREF
118  The native API function prototypes are defined in the header file \fBpcre.h\fR,  \fBpcreposix\fP
119  and on Unix systems the library itself is called \fBlibpcre.a\fR, so can be  .\"
120  accessed by adding \fB-lpcre\fR to the command for linking an application which  documentation.
121  calls it. The header file defines the macros PCRE_MAJOR and PCRE_MINOR to  .P
122  contain the major and minor release numbers for the library. Applications can  The native API function prototypes are defined in the header file \fBpcre.h\fP,
123  use these to include support for different releases.  and on Unix systems the library itself is called \fBlibpcre\fP. It can
124    normally be accessed by adding \fB-lpcre\fP to the command for linking an
125  The functions \fBpcre_compile()\fR, \fBpcre_study()\fR, and \fBpcre_exec()\fR  application that uses PCRE. The header file defines the macros PCRE_MAJOR and
126    PCRE_MINOR to contain the major and minor release numbers for the library.
127    Applications can use these to include support for different releases of PCRE.
128    .P
129    The functions \fBpcre_compile()\fP, \fBpcre_study()\fP, and \fBpcre_exec()\fP
130  are used for compiling and matching regular expressions. A sample program that  are used for compiling and matching regular expressions. A sample program that
131  demonstrates the simplest way of using them is given in the file  demonstrates the simplest way of using them is provided in the file called
132  \fIpcredemo.c\fR. The \fBpcresample\fR documentation describes how to run it.  \fIpcredemo.c\fP in the source distribution. The
133    .\" HREF
134  There are convenience functions for extracting captured substrings from a  \fBpcresample\fP
135  matched subject string. They are:  .\"
136    documentation describes how to run it.
137    \fBpcre_copy_substring()\fR  .P
138    \fBpcre_copy_named_substring()\fR  In addition to the main compiling and matching functions, there are convenience
139    \fBpcre_get_substring()\fR  functions for extracting captured substrings from a matched subject string.
140    \fBpcre_get_named_substring()\fR  They are:
141    \fBpcre_get_substring_list()\fR  .sp
142      \fBpcre_copy_substring()\fP
143  \fBpcre_free_substring()\fR and \fBpcre_free_substring_list()\fR are also    \fBpcre_copy_named_substring()\fP
144      \fBpcre_get_substring()\fP
145      \fBpcre_get_named_substring()\fP
146      \fBpcre_get_substring_list()\fP
147      \fBpcre_get_stringnumber()\fP
148    .sp
149    \fBpcre_free_substring()\fP and \fBpcre_free_substring_list()\fP are also
150  provided, to free the memory used for extracted strings.  provided, to free the memory used for extracted strings.
151    .P
152  The function \fBpcre_maketables()\fR is used (optionally) to build a set of  The function \fBpcre_maketables()\fP is used to build a set of character tables
153  character tables in the current locale for passing to \fBpcre_compile()\fR.  in the current locale for passing to \fBpcre_compile()\fP or \fBpcre_exec()\fP.
154    This is an optional facility that is provided for specialist use. Most
155  The function \fBpcre_fullinfo()\fR is used to find out information about a  commonly, no special tables are passed, in which case internal tables that are
156  compiled pattern; \fBpcre_info()\fR is an obsolete version which returns only  generated when PCRE is built are used.
157    .P
158    The function \fBpcre_fullinfo()\fP is used to find out information about a
159    compiled pattern; \fBpcre_info()\fP is an obsolete version that returns only
160  some of the available information, but is retained for backwards compatibility.  some of the available information, but is retained for backwards compatibility.
161  The function \fBpcre_version()\fR returns a pointer to a string containing the  The function \fBpcre_version()\fP returns a pointer to a string containing the
162  version of PCRE and its date of release.  version of PCRE and its date of release.
163    .P
164  The global variables \fBpcre_malloc\fR and \fBpcre_free\fR initially contain  The global variables \fBpcre_malloc\fP and \fBpcre_free\fP initially contain
165  the entry points of the standard \fBmalloc()\fR and \fBfree()\fR functions  the entry points of the standard \fBmalloc()\fP and \fBfree()\fP functions,
166  respectively. PCRE calls the memory management functions via these variables,  respectively. PCRE calls the memory management functions via these variables,
167  so a calling program can replace them if it wishes to intercept the calls. This  so a calling program can replace them if it wishes to intercept the calls. This
168  should be done before calling any PCRE functions.  should be done before calling any PCRE functions.
169    .P
170  The global variable \fBpcre_callout\fR initially contains NULL. It can be set  The global variables \fBpcre_stack_malloc\fP and \fBpcre_stack_free\fP are also
171    indirections to memory management functions. These special functions are used
172    only when PCRE is compiled to use the heap for remembering data, instead of
173    recursive function calls. This is a non-standard way of building PCRE, for use
174    in environments that have limited stacks. Because of the greater use of memory
175    management, it runs more slowly. Separate functions are provided so that
176    special-purpose external code can be used for this case. When used, these
177    functions are always called in a stack-like manner (last obtained, first
178    freed), and always for memory blocks of the same size.
179    .P
180    The global variable \fBpcre_callout\fP initially contains NULL. It can be set
181  by the caller to a "callout" function, which PCRE will then call at specified  by the caller to a "callout" function, which PCRE will then call at specified
182  points during a matching operation. Details are given in the \fBpcrecallout\fR  points during a matching operation. Details are given in the
183    .\" HREF
184    \fBpcrecallout\fP
185    .\"
186  documentation.  documentation.
187    .
188    .
189  .SH MULTITHREADING  .SH MULTITHREADING
190  .rs  .rs
191  .sp  .sp
192  The PCRE functions can be used in multi-threading applications, with the  The PCRE functions can be used in multi-threading applications, with the
193  proviso that the memory management functions pointed to by \fBpcre_malloc\fR  proviso that the memory management functions pointed to by \fBpcre_malloc\fP,
194  and \fBpcre_free\fR, and the callout function pointed to by \fBpcre_callout\fR,  \fBpcre_free\fP, \fBpcre_stack_malloc\fP, and \fBpcre_stack_free\fP, and the
195  are shared by all threads.  callout function pointed to by \fBpcre_callout\fP, are shared by all threads.
196    .P
197  The compiled form of a regular expression is not altered during matching, so  The compiled form of a regular expression is not altered during matching, so
198  the same compiled pattern can safely be used by several threads at once.  the same compiled pattern can safely be used by several threads at once.
199    .
200  .SH CHECKING BUILD-TIME OPTIONS  .
201    .SH "SAVING PRECOMPILED PATTERNS FOR LATER USE"
202  .rs  .rs
203  .sp  .sp
204  .B int pcre_config(int \fIwhat\fR, void *\fIwhere\fR);  The compiled form of a regular expression can be saved and re-used at a later
205    time, possibly by a different program, and even on a host other than the one on
206    which it was compiled. Details are given in the
207    .\" HREF
208    \fBpcreprecompile\fP
209    .\"
210    documentation.
211    .
212    .
213    .SH "CHECKING BUILD-TIME OPTIONS"
214    .rs
215    .sp
216    .B int pcre_config(int \fIwhat\fP, void *\fIwhere\fP);
217  .PP  .PP
218  The function \fBpcre_config()\fR makes it possible for a PCRE client to  The function \fBpcre_config()\fP makes it possible for a PCRE client to
219  discover which optional features have been compiled into the PCRE library. The  discover which optional features have been compiled into the PCRE library. The
220  .\" HREF  .\" HREF
221  \fBpcrebuild\fR  \fBpcrebuild\fP
222  .\"  .\"
223  documentation has more details about these optional features.  documentation has more details about these optional features.
224    .P
225  The first argument for \fBpcre_config()\fR is an integer, specifying which  The first argument for \fBpcre_config()\fP is an integer, specifying which
226  information is required; the second argument is a pointer to a variable into  information is required; the second argument is a pointer to a variable into
227  which the information is placed. The following information is available:  which the information is placed. The following information is available:
228    .sp
229    PCRE_CONFIG_UTF8    PCRE_CONFIG_UTF8
230    .sp
231  The output is an integer that is set to one if UTF-8 support is available;  The output is an integer that is set to one if UTF-8 support is available;
232  otherwise it is set to zero.  otherwise it is set to zero.
233    .sp
234      PCRE_CONFIG_UNICODE_PROPERTIES
235    .sp
236    The output is an integer that is set to one if support for Unicode character
237    properties is available; otherwise it is set to zero.
238    .sp
239    PCRE_CONFIG_NEWLINE    PCRE_CONFIG_NEWLINE
240    .sp
241  The output is an integer that is set to the value of the code that is used for  The output is an integer that is set to the value of the code that is used for
242  the newline character. It is either linefeed (10) or carriage return (13), and  the newline character. It is either linefeed (10) or carriage return (13), and
243  should normally be the standard character for your operating system.  should normally be the standard character for your operating system.
244    .sp
245    PCRE_CONFIG_LINK_SIZE    PCRE_CONFIG_LINK_SIZE
246    .sp
247  The output is an integer that contains the number of bytes used for internal  The output is an integer that contains the number of bytes used for internal
248  linkage in compiled regular expressions. The value is 2, 3, or 4. Larger values  linkage in compiled regular expressions. The value is 2, 3, or 4. Larger values
249  allow larger regular expressions to be compiled, at the expense of slower  allow larger regular expressions to be compiled, at the expense of slower
250  matching. The default value of 2 is sufficient for all but the most massive  matching. The default value of 2 is sufficient for all but the most massive
251  patterns, since it allows the compiled pattern to be up to 64K in size.  patterns, since it allows the compiled pattern to be up to 64K in size.
252    .sp
253    PCRE_CONFIG_POSIX_MALLOC_THRESHOLD    PCRE_CONFIG_POSIX_MALLOC_THRESHOLD
254    .sp
255  The output is an integer that contains the threshold above which the POSIX  The output is an integer that contains the threshold above which the POSIX
256  interface uses \fBmalloc()\fR for output vectors. Further details are given in  interface uses \fBmalloc()\fP for output vectors. Further details are given in
257  the \fBpcreposix\fR documentation.  the
258    .\" HREF
259    \fBpcreposix\fP
260    .\"
261    documentation.
262    .sp
263    PCRE_CONFIG_MATCH_LIMIT    PCRE_CONFIG_MATCH_LIMIT
264    .sp
265  The output is an integer that gives the default limit for the number of  The output is an integer that gives the default limit for the number of
266  internal matching function calls in a \fBpcre_exec()\fR execution. Further  internal matching function calls in a \fBpcre_exec()\fP execution. Further
267  details are given with \fBpcre_exec()\fR below.  details are given with \fBpcre_exec()\fP below.
268    .sp
269  .SH COMPILING A PATTERN    PCRE_CONFIG_STACKRECURSE
270    .sp
271    The output is an integer that is set to one if internal recursion is
272    implemented by recursive function calls that use the stack to remember their
273    state. This is the usual way that PCRE is compiled. The output is zero if PCRE
274    was compiled to use blocks of data on the heap instead of recursive function
275    calls. In this case, \fBpcre_stack_malloc\fP and \fBpcre_stack_free\fP are
276    called to manage memory blocks on the heap, thus avoiding the use of the stack.
277    .
278    .
279    .SH "COMPILING A PATTERN"
280  .rs  .rs
281  .sp  .sp
282  .B pcre *pcre_compile(const char *\fIpattern\fR, int \fIoptions\fR,  .B pcre *pcre_compile(const char *\fIpattern\fP, int \fIoptions\fP,
283  .ti +5n  .ti +5n
284  .B const char **\fIerrptr\fR, int *\fIerroffset\fR,  .B const char **\fIerrptr\fP, int *\fIerroffset\fP,
285  .ti +5n  .ti +5n
286  .B const unsigned char *\fItableptr\fR);  .B const unsigned char *\fItableptr\fP);
287  .PP  .P
288    The function \fBpcre_compile()\fP is called to compile a pattern into an
 The function \fBpcre_compile()\fR is called to compile a pattern into an  
289  internal form. The pattern is a C string terminated by a binary zero, and  internal form. The pattern is a C string terminated by a binary zero, and
290  is passed in the argument \fIpattern\fR. A pointer to a single block of memory  is passed in the \fIpattern\fP argument. A pointer to a single block of memory
291  that is obtained via \fBpcre_malloc\fR is returned. This contains the compiled  that is obtained via \fBpcre_malloc\fP is returned. This contains the compiled
292  code and related data. The \fBpcre\fR type is defined for the returned block;  code and related data. The \fBpcre\fP type is defined for the returned block;
293  this is a typedef for a structure whose contents are not externally defined. It  this is a typedef for a structure whose contents are not externally defined. It
294  is up to the caller to free the memory when it is no longer required.  is up to the caller to free the memory when it is no longer required.
295    .P
296  Although the compiled code of a PCRE regex is relocatable, that is, it does not  Although the compiled code of a PCRE regex is relocatable, that is, it does not
297  depend on memory location, the complete \fBpcre\fR data block is not  depend on memory location, the complete \fBpcre\fP data block is not
298  fully relocatable, because it contains a copy of the \fItableptr\fR argument,  fully relocatable, because it may contain a copy of the \fItableptr\fP
299  which is an address (see below).  argument, which is an address (see below).
300    .P
301  The \fIoptions\fR argument contains independent bits that affect the  The \fIoptions\fP argument contains independent bits that affect the
302  compilation. It should be zero if no options are required. Some of the options,  compilation. It should be zero if no options are required. The available
303  in particular, those that are compatible with Perl, can also be set and unset  options are described below. Some of them, in particular, those that are
304  from within the pattern (see the detailed description of regular expressions  compatible with Perl, can also be set and unset from within the pattern (see
305  in the \fBpcrepattern\fR documentation). For these options, the contents of the  the detailed description in the
306  \fIoptions\fR argument specifies their initial settings at the start of  .\" HREF
307  compilation and execution. The PCRE_ANCHORED option can be set at the time of  \fBpcrepattern\fP
308  matching as well as at compile time.  .\"
309    documentation). For these options, the contents of the \fIoptions\fP argument
310  If \fIerrptr\fR is NULL, \fBpcre_compile()\fR returns NULL immediately.  specifies their initial settings at the start of compilation and execution. The
311  Otherwise, if compilation of a pattern fails, \fBpcre_compile()\fR returns  PCRE_ANCHORED option can be set at the time of matching as well as at compile
312  NULL, and sets the variable pointed to by \fIerrptr\fR to point to a textual  time.
313    .P
314    If \fIerrptr\fP is NULL, \fBpcre_compile()\fP returns NULL immediately.
315    Otherwise, if compilation of a pattern fails, \fBpcre_compile()\fP returns
316    NULL, and sets the variable pointed to by \fIerrptr\fP to point to a textual
317  error message. The offset from the start of the pattern to the character where  error message. The offset from the start of the pattern to the character where
318  the error was discovered is placed in the variable pointed to by  the error was discovered is placed in the variable pointed to by
319  \fIerroffset\fR, which must not be NULL. If it is, an immediate error is given.  \fIerroffset\fP, which must not be NULL. If it is, an immediate error is given.
320    .P
321  If the final argument, \fItableptr\fR, is NULL, PCRE uses a default set of  If the final argument, \fItableptr\fP, is NULL, PCRE uses a default set of
322  character tables which are built when it is compiled, using the default C  character tables that are built when PCRE is compiled, using the default C
323  locale. Otherwise, \fItableptr\fR must be the result of a call to  locale. Otherwise, \fItableptr\fP must be an address that is the result of a
324  \fBpcre_maketables()\fR. See the section on locale support below.  call to \fBpcre_maketables()\fP. This value is stored with the compiled
325    pattern, and used again by \fBpcre_exec()\fP, unless another table pointer is
326  This code fragment shows a typical straightforward call to \fBpcre_compile()\fR:  passed to it. For more discussion, see the section on locale support below.
327    .P
328    This code fragment shows a typical straightforward call to \fBpcre_compile()\fP:
329    .sp
330    pcre *re;    pcre *re;
331    const char *error;    const char *error;
332    int erroffset;    int erroffset;
# Line 265  This code fragment shows a typical strai Line 336  This code fragment shows a typical strai
336      &error,           /* for error message */      &error,           /* for error message */
337      &erroffset,       /* for error offset */      &erroffset,       /* for error offset */
338      NULL);            /* use default character tables */      NULL);            /* use default character tables */
339    .sp
340  The following option bits are defined:  The following names for option bits are defined in the \fBpcre.h\fP header
341    file:
342    .sp
343    PCRE_ANCHORED    PCRE_ANCHORED
344    .sp
345  If this bit is set, the pattern is forced to be "anchored", that is, it is  If this bit is set, the pattern is forced to be "anchored", that is, it is
346  constrained to match only at the first matching point in the string which is  constrained to match only at the first matching point in the string that is
347  being searched (the "subject string"). This effect can also be achieved by  being searched (the "subject string"). This effect can also be achieved by
348  appropriate constructs in the pattern itself, which is the only way to do it in  appropriate constructs in the pattern itself, which is the only way to do it in
349  Perl.  Perl.
350    .sp
351      PCRE_AUTO_CALLOUT
352    .sp
353    If this bit is set, \fBpcre_compile()\fP automatically inserts callout items,
354    all with number 255, before each pattern item. For discussion of the callout
355    facility, see the
356    .\" HREF
357    \fBpcrecallout\fP
358    .\"
359    documentation.
360    .sp
361    PCRE_CASELESS    PCRE_CASELESS
362    .sp
363  If this bit is set, letters in the pattern match both upper and lower case  If this bit is set, letters in the pattern match both upper and lower case
364  letters. It is equivalent to Perl's /i option, and it can be changed within a  letters. It is equivalent to Perl's /i option, and it can be changed within a
365  pattern by a (?i) option setting.  pattern by a (?i) option setting. When running in UTF-8 mode, case support for
366    high-valued characters is available only when PCRE is built with Unicode
367    character property support.
368    .sp
369    PCRE_DOLLAR_ENDONLY    PCRE_DOLLAR_ENDONLY
370    .sp
371  If this bit is set, a dollar metacharacter in the pattern matches only at the  If this bit is set, a dollar metacharacter in the pattern matches only at the
372  end of the subject string. Without this option, a dollar also matches  end of the subject string. Without this option, a dollar also matches
373  immediately before the final character if it is a newline (but not before any  immediately before the final character if it is a newline (but not before any
374  other newlines). The PCRE_DOLLAR_ENDONLY option is ignored if PCRE_MULTILINE is  other newlines). The PCRE_DOLLAR_ENDONLY option is ignored if PCRE_MULTILINE is
375  set. There is no equivalent to this option in Perl, and no way to set it within  set. There is no equivalent to this option in Perl, and no way to set it within
376  a pattern.  a pattern.
377    .sp
378    PCRE_DOTALL    PCRE_DOTALL
379    .sp
380  If this bit is set, a dot metacharater in the pattern matches all characters,  If this bit is set, a dot metacharater in the pattern matches all characters,
381  including newlines. Without it, newlines are excluded. This option is  including newlines. Without it, newlines are excluded. This option is
382  equivalent to Perl's /s option, and it can be changed within a pattern by a  equivalent to Perl's /s option, and it can be changed within a pattern by a
383  (?s) option setting. A negative class such as [^a] always matches a newline  (?s) option setting. A negative class such as [^a] always matches a newline
384  character, independent of the setting of this option.  character, independent of the setting of this option.
385    .sp
386    PCRE_EXTENDED    PCRE_EXTENDED
387    .sp
388  If this bit is set, whitespace data characters in the pattern are totally  If this bit is set, whitespace data characters in the pattern are totally
389  ignored except when escaped or inside a character class. Whitespace does not  ignored except when escaped or inside a character class. Whitespace does not
390  include the VT character (code 11). In addition, characters between an  include the VT character (code 11). In addition, characters between an
391  unescaped # outside a character class and the next newline character,  unescaped # outside a character class and the next newline character,
392  inclusive, are also ignored. This is equivalent to Perl's /x option, and it can  inclusive, are also ignored. This is equivalent to Perl's /x option, and it can
393  be changed within a pattern by a (?x) option setting.  be changed within a pattern by a (?x) option setting.
394    .P
395  This option makes it possible to include comments inside complicated patterns.  This option makes it possible to include comments inside complicated patterns.
396  Note, however, that this applies only to data characters. Whitespace characters  Note, however, that this applies only to data characters. Whitespace characters
397  may never appear within special character sequences in a pattern, for example  may never appear within special character sequences in a pattern, for example
398  within the sequence (?( which introduces a conditional subpattern.  within the sequence (?( which introduces a conditional subpattern.
399    .sp
400    PCRE_EXTRA    PCRE_EXTRA
401    .sp
402  This option was invented in order to turn on additional functionality of PCRE  This option was invented in order to turn on additional functionality of PCRE
403  that is incompatible with Perl, but it is currently of very little use. When  that is incompatible with Perl, but it is currently of very little use. When
404  set, any backslash in a pattern that is followed by a letter that has no  set, any backslash in a pattern that is followed by a letter that has no
# Line 323  expansion. By default, as in Perl, a bac Line 407  expansion. By default, as in Perl, a bac
407  special meaning is treated as a literal. There are at present no other features  special meaning is treated as a literal. There are at present no other features
408  controlled by this option. It can also be set by a (?X) option setting within a  controlled by this option. It can also be set by a (?X) option setting within a
409  pattern.  pattern.
410    .sp
411    PCRE_MULTILINE    PCRE_MULTILINE
412    .sp
413  By default, PCRE treats the subject string as consisting of a single "line" of  By default, PCRE treats the subject string as consisting of a single line of
414  characters (even if it actually contains several newlines). The "start of line"  characters (even if it actually contains newlines). The "start of line"
415  metacharacter (^) matches only at the start of the string, while the "end of  metacharacter (^) matches only at the start of the string, while the "end of
416  line" metacharacter ($) matches only at the end of the string, or before a  line" metacharacter ($) matches only at the end of the string, or before a
417  terminating newline (unless PCRE_DOLLAR_ENDONLY is set). This is the same as  terminating newline (unless PCRE_DOLLAR_ENDONLY is set). This is the same as
418  Perl.  Perl.
419    .P
420  When PCRE_MULTILINE it is set, the "start of line" and "end of line" constructs  When PCRE_MULTILINE it is set, the "start of line" and "end of line" constructs
421  match immediately following or immediately before any newline in the subject  match immediately following or immediately before any newline in the subject
422  string, respectively, as well as at the very start and end. This is equivalent  string, respectively, as well as at the very start and end. This is equivalent
423  to Perl's /m option, and it can be changed within a pattern by a (?m) option  to Perl's /m option, and it can be changed within a pattern by a (?m) option
424  setting. If there are no "\\n" characters in a subject string, or no  setting. If there are no "\en" characters in a subject string, or no
425  occurrences of ^ or $ in a pattern, setting PCRE_MULTILINE has no effect.  occurrences of ^ or $ in a pattern, setting PCRE_MULTILINE has no effect.
426    .sp
427    PCRE_NO_AUTO_CAPTURE    PCRE_NO_AUTO_CAPTURE
428    .sp
429  If this option is set, it disables the use of numbered capturing parentheses in  If this option is set, it disables the use of numbered capturing parentheses in
430  the pattern. Any opening parenthesis that is not followed by ? behaves as if it  the pattern. Any opening parenthesis that is not followed by ? behaves as if it
431  were followed by ?: but named parentheses can still be used for capturing (and  were followed by ?: but named parentheses can still be used for capturing (and
432  they acquire numbers in the usual way). There is no equivalent of this option  they acquire numbers in the usual way). There is no equivalent of this option
433  in Perl.  in Perl.
434    .sp
435    PCRE_UNGREEDY    PCRE_UNGREEDY
436    .sp
437  This option inverts the "greediness" of the quantifiers so that they are not  This option inverts the "greediness" of the quantifiers so that they are not
438  greedy by default, but become greedy if followed by "?". It is not compatible  greedy by default, but become greedy if followed by "?". It is not compatible
439  with Perl. It can also be set by a (?U) option setting within the pattern.  with Perl. It can also be set by a (?U) option setting within the pattern.
440    .sp
441    PCRE_UTF8    PCRE_UTF8
442    .sp
443  This option causes PCRE to regard both the pattern and the subject as strings  This option causes PCRE to regard both the pattern and the subject as strings
444  of UTF-8 characters instead of single-byte character strings. However, it is  of UTF-8 characters instead of single-byte character strings. However, it is
445  available only if PCRE has been built to include UTF-8 support. If not, the use  available only when PCRE is built to include UTF-8 support. If not, the use
446  of this option provokes an error. Details of how this option changes the  of this option provokes an error. Details of how this option changes the
447  behaviour of PCRE are given in the  behaviour of PCRE are given in the
448  .\" HTML <a href="pcre.html#utf8support">  .\" HTML <a href="pcre.html#utf8support">
# Line 367  section on UTF-8 support Line 451  section on UTF-8 support
451  .\"  .\"
452  in the main  in the main
453  .\" HREF  .\" HREF
454  \fBpcre\fR  \fBpcre\fP
455  .\"  .\"
456  page.  page.
457    .sp
458  .SH STUDYING A PATTERN    PCRE_NO_UTF8_CHECK
459    .sp
460    When PCRE_UTF8 is set, the validity of the pattern as a UTF-8 string is
461    automatically checked. If an invalid UTF-8 sequence of bytes is found,
462    \fBpcre_compile()\fP returns an error. If you already know that your pattern is
463    valid, and you want to skip this check for performance reasons, you can set the
464    PCRE_NO_UTF8_CHECK option. When it is set, the effect of passing an invalid
465    UTF-8 string as a pattern is undefined. It may cause your program to crash.
466    Note that this option can also be passed to \fBpcre_exec()\fP, to suppress the
467    UTF-8 validity checking of subject strings.
468    .
469    .
470    .SH "STUDYING A PATTERN"
471  .rs  .rs
472  .sp  .sp
473  .B pcre_extra *pcre_study(const pcre *\fIcode\fR, int \fIoptions\fR,  .B pcre_extra *pcre_study(const pcre *\fIcode\fP, int \fIoptions\fP,
474  .ti +5n  .ti +5n
475  .B const char **\fIerrptr\fR);  .B const char **\fIerrptr\fP);
476  .PP  .PP
477  When a pattern is going to be used several times, it is worth spending more  If a compiled pattern is going to be used several times, it is worth spending
478  time analyzing it in order to speed up the time taken for matching. The  more time analyzing it in order to speed up the time taken for matching. The
479  function \fBpcre_study()\fR takes a pointer to a compiled pattern as its first  function \fBpcre_study()\fP takes a pointer to a compiled pattern as its first
480  argument. If studing the pattern produces additional information that will help  argument. If studying the pattern produces additional information that will
481  speed up matching, \fBpcre_study()\fR returns a pointer to a \fBpcre_extra\fR  help speed up matching, \fBpcre_study()\fP returns a pointer to a
482  block, in which the \fIstudy_data\fR field points to the results of the study.  \fBpcre_extra\fP block, in which the \fIstudy_data\fP field points to the
483    results of the study.
484  The returned value from a \fBpcre_study()\fR can be passed directly to  .P
485  \fBpcre_exec()\fR. However, the \fBpcre_extra\fR block also contains other  The returned value from \fBpcre_study()\fP can be passed directly to
486    \fBpcre_exec()\fP. However, a \fBpcre_extra\fP block also contains other
487  fields that can be set by the caller before the block is passed; these are  fields that can be set by the caller before the block is passed; these are
488  described below. If studying the pattern does not produce any additional  described
489  information, \fBpcre_study()\fR returns NULL. In that circumstance, if the  .\" HTML <a href="#extradata">
490  calling program wants to pass some of the other fields to \fBpcre_exec()\fR, it  .\" </a>
491  must set up its own \fBpcre_extra\fR block.  below
492    .\"
493  The second argument contains option bits. At present, no options are defined  in the section on matching a pattern.
494  for \fBpcre_study()\fR, and this argument should always be zero.  .P
495    If studying the pattern does not produce any additional information,
496  The third argument for \fBpcre_study()\fR is a pointer for an error message. If  \fBpcre_study()\fP returns NULL. In that circumstance, if the calling program
497    wants to pass any of the other fields to \fBpcre_exec()\fP, it must set up its
498    own \fBpcre_extra\fP block.
499    .P
500    The second argument of \fBpcre_study()\fP contains option bits. At present, no
501    options are defined, and this argument should always be zero.
502    .P
503    The third argument for \fBpcre_study()\fP is a pointer for an error message. If
504  studying succeeds (even if no data is returned), the variable it points to is  studying succeeds (even if no data is returned), the variable it points to is
505  set to NULL. Otherwise it points to a textual error message. You should  set to NULL. Otherwise it points to a textual error message. You should
506  therefore test the error pointer for NULL after calling \fBpcre_study()\fR, to  therefore test the error pointer for NULL after calling \fBpcre_study()\fP, to
507  be sure that it has run successfully.  be sure that it has run successfully.
508    .P
509  This is a typical call to \fBpcre_study\fR():  This is a typical call to \fBpcre_study\fP():
510    .sp
511    pcre_extra *pe;    pcre_extra *pe;
512    pe = pcre_study(    pe = pcre_study(
513      re,             /* result of pcre_compile() */      re,             /* result of pcre_compile() */
514      0,              /* no options exist */      0,              /* no options exist */
515      &error);        /* set to NULL or points to a message */      &error);        /* set to NULL or points to a message */
516    .sp
517  At present, studying a pattern is useful only for non-anchored patterns that do  At present, studying a pattern is useful only for non-anchored patterns that do
518  not have a single fixed starting character. A bitmap of possible starting  not have a single fixed starting character. A bitmap of possible starting
519  characters is created.  bytes is created.
520    .
521    .
522  .\" HTML <a name="localesupport"></a>  .\" HTML <a name="localesupport"></a>
523  .SH LOCALE SUPPORT  .SH "LOCALE SUPPORT"
524  .rs  .rs
525  .sp  .sp
526  PCRE handles caseless matching, and determines whether characters are letters,  PCRE handles caseless matching, and determines whether characters are letters,
527  digits, or whatever, by reference to a set of tables. When running in UTF-8  digits, or whatever, by reference to a set of tables, indexed by character
528  mode, this applies only to characters with codes less than 256. The library  value. (When running in UTF-8 mode, this applies only to characters with codes
529  contains a default set of tables that is created in the default C locale when  less than 128. Higher-valued codes never match escapes such as \ew or \ed, but
530  PCRE is compiled. This is used when the final argument of \fBpcre_compile()\fR  can be tested with \ep if PCRE is built with Unicode character property
531  is NULL, and is sufficient for many applications.  support.)
532    .P
533  An alternative set of tables can, however, be supplied. Such tables are built  An internal set of tables is created in the default C locale when PCRE is
534  by calling the \fBpcre_maketables()\fR function, which has no arguments, in the  built. This is used when the final argument of \fBpcre_compile()\fP is NULL,
535  relevant locale. The result can then be passed to \fBpcre_compile()\fR as often  and is sufficient for many applications. An alternative set of tables can,
536  as necessary. For example, to build and use tables that are appropriate for the  however, be supplied. These may be created in a different locale from the
537  French locale (where accented characters with codes greater than 128 are  default. As more and more applications change to using Unicode, the need for
538  treated as letters), the following code could be used:  this locale support is expected to die away.
539    .P
540    setlocale(LC_CTYPE, "fr");  External tables are built by calling the \fBpcre_maketables()\fP function,
541    which has no arguments, in the relevant locale. The result can then be passed
542    to \fBpcre_compile()\fP or \fBpcre_exec()\fP as often as necessary. For
543    example, to build and use tables that are appropriate for the French locale
544    (where accented characters with values greater than 128 are treated as letters),
545    the following code could be used:
546    .sp
547      setlocale(LC_CTYPE, "fr_FR");
548    tables = pcre_maketables();    tables = pcre_maketables();
549    re = pcre_compile(..., tables);    re = pcre_compile(..., tables);
550    .sp
551  The tables are built in memory that is obtained via \fBpcre_malloc\fR. The  When \fBpcre_maketables()\fP runs, the tables are built in memory that is
552  pointer that is passed to \fBpcre_compile\fR is saved with the compiled  obtained via \fBpcre_malloc\fP. It is the caller's responsibility to ensure
553  pattern, and the same tables are used via this pointer by \fBpcre_study()\fR  that the memory containing the tables remains available for as long as it is
554  and \fBpcre_exec()\fR. Thus, for any single pattern, compilation, studying and  needed.
555  matching all happen in the same locale, but different patterns can be compiled  .P
556  in different locales. It is the caller's responsibility to ensure that the  The pointer that is passed to \fBpcre_compile()\fP is saved with the compiled
557  memory containing the tables remains available for as long as it is needed.  pattern, and the same tables are used via this pointer by \fBpcre_study()\fP
558    and normally also by \fBpcre_exec()\fP. Thus, by default, for any single
559  .SH INFORMATION ABOUT A PATTERN  pattern, compilation, studying and matching all happen in the same locale, but
560    different patterns can be compiled in different locales.
561    .P
562    It is possible to pass a table pointer or NULL (indicating the use of the
563    internal tables) to \fBpcre_exec()\fP. Although not intended for this purpose,
564    this facility could be used to match a pattern in a different locale from the
565    one in which it was compiled. Passing table pointers at run time is discussed
566    below in the section on matching a pattern.
567    .
568    .
569    .SH "INFORMATION ABOUT A PATTERN"
570  .rs  .rs
571  .sp  .sp
572  .B int pcre_fullinfo(const pcre *\fIcode\fR, "const pcre_extra *\fIextra\fR,"  .B int pcre_fullinfo(const pcre *\fIcode\fP, "const pcre_extra *\fIextra\fP,"
573  .ti +5n  .ti +5n
574  .B int \fIwhat\fR, void *\fIwhere\fR);  .B int \fIwhat\fP, void *\fIwhere\fP);
575  .PP  .PP
576  The \fBpcre_fullinfo()\fR function returns information about a compiled  The \fBpcre_fullinfo()\fP function returns information about a compiled
577  pattern. It replaces the obsolete \fBpcre_info()\fR function, which is  pattern. It replaces the obsolete \fBpcre_info()\fP function, which is
578  nevertheless retained for backwards compability (and is documented below).  nevertheless retained for backwards compability (and is documented below).
579    .P
580  The first argument for \fBpcre_fullinfo()\fR is a pointer to the compiled  The first argument for \fBpcre_fullinfo()\fP is a pointer to the compiled
581  pattern. The second argument is the result of \fBpcre_study()\fR, or NULL if  pattern. The second argument is the result of \fBpcre_study()\fP, or NULL if
582  the pattern was not studied. The third argument specifies which piece of  the pattern was not studied. The third argument specifies which piece of
583  information is required, and the fourth argument is a pointer to a variable  information is required, and the fourth argument is a pointer to a variable
584  to receive the data. The yield of the function is zero for success, or one of  to receive the data. The yield of the function is zero for success, or one of
585  the following negative numbers:  the following negative numbers:
586    .sp
587    PCRE_ERROR_NULL       the argument \fIcode\fR was NULL    PCRE_ERROR_NULL       the argument \fIcode\fP was NULL
588                          the argument \fIwhere\fR was NULL                          the argument \fIwhere\fP was NULL
589    PCRE_ERROR_BADMAGIC   the "magic number" was not found    PCRE_ERROR_BADMAGIC   the "magic number" was not found
590    PCRE_ERROR_BADOPTION  the value of \fIwhat\fR was invalid    PCRE_ERROR_BADOPTION  the value of \fIwhat\fP was invalid
591    .sp
592  Here is a typical call of \fBpcre_fullinfo()\fR, to obtain the length of the  The "magic number" is placed at the start of each compiled pattern as an simple
593  compiled pattern:  check against passing an arbitrary memory pointer. Here is a typical call of
594    \fBpcre_fullinfo()\fP, to obtain the length of the compiled pattern:
595    .sp
596    int rc;    int rc;
597    unsigned long int length;    unsigned long int length;
598    rc = pcre_fullinfo(    rc = pcre_fullinfo(
# Line 477  compiled pattern: Line 600  compiled pattern:
600      pe,               /* result of pcre_study(), or NULL */      pe,               /* result of pcre_study(), or NULL */
601      PCRE_INFO_SIZE,   /* what is required */      PCRE_INFO_SIZE,   /* what is required */
602      &length);         /* where to put the data */      &length);         /* where to put the data */
603    .sp
604  The possible values for the third argument are defined in \fBpcre.h\fR, and are  The possible values for the third argument are defined in \fBpcre.h\fP, and are
605  as follows:  as follows:
606    .sp
607    PCRE_INFO_BACKREFMAX    PCRE_INFO_BACKREFMAX
608    .sp
609  Return the number of the highest back reference in the pattern. The fourth  Return the number of the highest back reference in the pattern. The fourth
610  argument should point to an \fBint\fR variable. Zero is returned if there are  argument should point to an \fBint\fP variable. Zero is returned if there are
611  no back references.  no back references.
612    .sp
613    PCRE_INFO_CAPTURECOUNT    PCRE_INFO_CAPTURECOUNT
614    .sp
615  Return the number of capturing subpatterns in the pattern. The fourth argument  Return the number of capturing subpatterns in the pattern. The fourth argument
616  should point to an \fbint\fR variable.  should point to an \fBint\fP variable.
617    .sp
618      PCRE_INFO_DEFAULTTABLES
619    .sp
620    Return a pointer to the internal default character tables within PCRE. The
621    fourth argument should point to an \fBunsigned char *\fP variable. This
622    information call is provided for internal use by the \fBpcre_study()\fP
623    function. External callers can cause PCRE to use its internal tables by passing
624    a NULL table pointer.
625    .sp
626    PCRE_INFO_FIRSTBYTE    PCRE_INFO_FIRSTBYTE
627    .sp
628  Return information about the first byte of any matched string, for a  Return information about the first byte of any matched string, for a
629  non-anchored pattern. (This option used to be called PCRE_INFO_FIRSTCHAR; the  non-anchored pattern. (This option used to be called PCRE_INFO_FIRSTCHAR; the
630  old name is still recognized for backwards compatibility.)  old name is still recognized for backwards compatibility.)
631    .P
632  If there is a fixed first byte, e.g. from a pattern such as (cat|cow|coyote),  If there is a fixed first byte, for example, from a pattern such as
633  it is returned in the integer pointed to by \fIwhere\fR. Otherwise, if either  (cat|cow|coyote), it is returned in the integer pointed to by \fIwhere\fP.
634    Otherwise, if either
635    .sp
636  (a) the pattern was compiled with the PCRE_MULTILINE option, and every branch  (a) the pattern was compiled with the PCRE_MULTILINE option, and every branch
637  starts with "^", or  starts with "^", or
638    .sp
639  (b) every branch of the pattern starts with ".*" and PCRE_DOTALL is not set  (b) every branch of the pattern starts with ".*" and PCRE_DOTALL is not set
640  (if it were set, the pattern would be anchored),  (if it were set, the pattern would be anchored),
641    .sp
642  -1 is returned, indicating that the pattern matches only at the start of a  -1 is returned, indicating that the pattern matches only at the start of a
643  subject string or after any newline within the string. Otherwise -2 is  subject string or after any newline within the string. Otherwise -2 is
644  returned. For anchored patterns, -2 is returned.  returned. For anchored patterns, -2 is returned.
645    .sp
646    PCRE_INFO_FIRSTTABLE    PCRE_INFO_FIRSTTABLE
647    .sp
648  If the pattern was studied, and this resulted in the construction of a 256-bit  If the pattern was studied, and this resulted in the construction of a 256-bit
649  table indicating a fixed set of bytes for the first byte in any matching  table indicating a fixed set of bytes for the first byte in any matching
650  string, a pointer to the table is returned. Otherwise NULL is returned. The  string, a pointer to the table is returned. Otherwise NULL is returned. The
651  fourth argument should point to an \fBunsigned char *\fR variable.  fourth argument should point to an \fBunsigned char *\fP variable.
652    .sp
653    PCRE_INFO_LASTLITERAL    PCRE_INFO_LASTLITERAL
654    .sp
655  Return the value of the rightmost literal byte that must exist in any matched  Return the value of the rightmost literal byte that must exist in any matched
656  string, other than at its start, if such a byte has been recorded. The fourth  string, other than at its start, if such a byte has been recorded. The fourth
657  argument should point to an \fBint\fR variable. If there is no such byte, -1 is  argument should point to an \fBint\fP variable. If there is no such byte, -1 is
658  returned. For anchored patterns, a last literal byte is recorded only if it  returned. For anchored patterns, a last literal byte is recorded only if it
659  follows something of variable length. For example, for the pattern  follows something of variable length. For example, for the pattern
660  /^a\\d+z\\d+/ the returned value is "z", but for /^a\\dz\\d/ the returned value  /^a\ed+z\ed+/ the returned value is "z", but for /^a\edz\ed/ the returned value
661  is -1.  is -1.
662    .sp
663    PCRE_INFO_NAMECOUNT    PCRE_INFO_NAMECOUNT
664    PCRE_INFO_NAMEENTRYSIZE    PCRE_INFO_NAMEENTRYSIZE
665    PCRE_INFO_NAMETABLE    PCRE_INFO_NAMETABLE
666    .sp
667  PCRE supports the use of named as well as numbered capturing parentheses. The  PCRE supports the use of named as well as numbered capturing parentheses. The
668  names are just an additional way of identifying the parentheses, which still  names are just an additional way of identifying the parentheses, which still
669  acquire a number. A caller that wants to extract data from a named subpattern  acquire numbers. A convenience function called \fBpcre_get_named_substring()\fP
670  must convert the name to a number in order to access the correct pointers in  is provided for extracting an individual captured substring by name. It is also
671  the output vector (described with \fBpcre_exec()\fR below). In order to do  possible to extract the data directly, by first converting the name to a number
672  this, it must first use these three values to obtain the name-to-number mapping  in order to access the correct pointers in the output vector (described with
673  table for the pattern.  \fBpcre_exec()\fP below). To do the conversion, you need to use the
674    name-to-number map, which is described by these three values.
675    .P
676  The map consists of a number of fixed-size entries. PCRE_INFO_NAMECOUNT gives  The map consists of a number of fixed-size entries. PCRE_INFO_NAMECOUNT gives
677  the number of entries, and PCRE_INFO_NAMEENTRYSIZE gives the size of each  the number of entries, and PCRE_INFO_NAMEENTRYSIZE gives the size of each
678  entry; both of these return an \fBint\fR value. The entry size depends on the  entry; both of these return an \fBint\fP value. The entry size depends on the
679  length of the longest name. PCRE_INFO_NAMETABLE returns a pointer to the first  length of the longest name. PCRE_INFO_NAMETABLE returns a pointer to the first
680  entry of the table (a pointer to \fBchar\fR). The first two bytes of each entry  entry of the table (a pointer to \fBchar\fP). The first two bytes of each entry
681  are the number of the capturing parenthesis, most significant byte first. The  are the number of the capturing parenthesis, most significant byte first. The
682  rest of the entry is the corresponding name, zero terminated. The names are in  rest of the entry is the corresponding name, zero terminated. The names are in
683  alphabetical order. For example, consider the following pattern (assume  alphabetical order. For example, consider the following pattern (assume
684  PCRE_EXTENDED is set, so white space - including newlines - is ignored):  PCRE_EXTENDED is set, so white space - including newlines - is ignored):
685    .sp
686    (?P<date> (?P<year>(\\d\\d)?\\d\\d) -  .\" JOIN
687    (?P<month>\\d\\d) - (?P<day>\\d\\d) )    (?P<date> (?P<year>(\ed\ed)?\ed\ed) -
688      (?P<month>\ed\ed) - (?P<day>\ed\ed) )
689    .sp
690  There are four named subpatterns, so the table has four entries, and each entry  There are four named subpatterns, so the table has four entries, and each entry
691  in the table is eight bytes long. The table is as follows, with non-printing  in the table is eight bytes long. The table is as follows, with non-printing
692  bytes shows in hex, and undefined bytes shown as ??:  bytes shows in hexadecimal, and undefined bytes shown as ??:
693    .sp
694    00 01 d  a  t  e  00 ??    00 01 d  a  t  e  00 ??
695    00 05 d  a  y  00 ?? ??    00 05 d  a  y  00 ?? ??
696    00 04 m  o  n  t  h  00    00 04 m  o  n  t  h  00
697    00 02 y  e  a  r  00 ??    00 02 y  e  a  r  00 ??
698    .sp
699  When writing code to extract data from named subpatterns, remember that the  When writing code to extract data from named subpatterns using the
700  length of each entry may be different for each compiled pattern.  name-to-number map, remember that the length of each entry is likely to be
701    different for each compiled pattern.
702    .sp
703    PCRE_INFO_OPTIONS    PCRE_INFO_OPTIONS
704    .sp
705  Return a copy of the options with which the pattern was compiled. The fourth  Return a copy of the options with which the pattern was compiled. The fourth
706  argument should point to an \fBunsigned long int\fR variable. These option bits  argument should point to an \fBunsigned long int\fP variable. These option bits
707  are those specified in the call to \fBpcre_compile()\fR, modified by any  are those specified in the call to \fBpcre_compile()\fP, modified by any
708  top-level option settings within the pattern itself.  top-level option settings within the pattern itself.
709    .P
710  A pattern is automatically anchored by PCRE if all of its top-level  A pattern is automatically anchored by PCRE if all of its top-level
711  alternatives begin with one of the following:  alternatives begin with one of the following:
712    .sp
713    ^     unless PCRE_MULTILINE is set    ^     unless PCRE_MULTILINE is set
714    \\A    always    \eA    always
715    \\G    always    \eG    always
716    .\" JOIN
717    .*    if PCRE_DOTALL is set and there are no back    .*    if PCRE_DOTALL is set and there are no back
718            references to the subpattern in which .* appears            references to the subpattern in which .* appears
719    .sp
720  For such patterns, the PCRE_ANCHORED bit is set in the options returned by  For such patterns, the PCRE_ANCHORED bit is set in the options returned by
721  \fBpcre_fullinfo()\fR.  \fBpcre_fullinfo()\fP.
722    .sp
723    PCRE_INFO_SIZE    PCRE_INFO_SIZE
724    .sp
725  Return the size of the compiled pattern, that is, the value that was passed as  Return the size of the compiled pattern, that is, the value that was passed as
726  the argument to \fBpcre_malloc()\fR when PCRE was getting memory in which to  the argument to \fBpcre_malloc()\fP when PCRE was getting memory in which to
727  place the compiled data. The fourth argument should point to a \fBsize_t\fR  place the compiled data. The fourth argument should point to a \fBsize_t\fP
728  variable.  variable.
729    .sp
730    PCRE_INFO_STUDYSIZE    PCRE_INFO_STUDYSIZE
731    .sp
732  Returns the size of the data block pointed to by the \fIstudy_data\fR field in  Return the size of the data block pointed to by the \fIstudy_data\fP field in
733  a \fBpcre_extra\fR block. That is, it is the value that was passed to  a \fBpcre_extra\fP block. That is, it is the value that was passed to
734  \fBpcre_malloc()\fR when PCRE was getting memory into which to place the data  \fBpcre_malloc()\fP when PCRE was getting memory into which to place the data
735  created by \fBpcre_study()\fR. The fourth argument should point to a  created by \fBpcre_study()\fP. The fourth argument should point to a
736  \fBsize_t\fR variable.  \fBsize_t\fP variable.
737    .
738  .SH OBSOLETE INFO FUNCTION  .
739    .SH "OBSOLETE INFO FUNCTION"
740  .rs  .rs
741  .sp  .sp
742  .B int pcre_info(const pcre *\fIcode\fR, int *\fIoptptr\fR, int  .B int pcre_info(const pcre *\fIcode\fP, int *\fIoptptr\fP, int
743  .B *\fIfirstcharptr\fR);  .B *\fIfirstcharptr\fP);
744  .PP  .PP
745  The \fBpcre_info()\fR function is now obsolete because its interface is too  The \fBpcre_info()\fP function is now obsolete because its interface is too
746  restrictive to return all the available data about a compiled pattern. New  restrictive to return all the available data about a compiled pattern. New
747  programs should use \fBpcre_fullinfo()\fR instead. The yield of  programs should use \fBpcre_fullinfo()\fP instead. The yield of
748  \fBpcre_info()\fR is the number of capturing subpatterns, or one of the  \fBpcre_info()\fP is the number of capturing subpatterns, or one of the
749  following negative numbers:  following negative numbers:
750    .sp
751    PCRE_ERROR_NULL       the argument \fIcode\fR was NULL    PCRE_ERROR_NULL       the argument \fIcode\fP was NULL
752    PCRE_ERROR_BADMAGIC   the "magic number" was not found    PCRE_ERROR_BADMAGIC   the "magic number" was not found
753    .sp
754  If the \fIoptptr\fR argument is not NULL, a copy of the options with which the  If the \fIoptptr\fP argument is not NULL, a copy of the options with which the
755  pattern was compiled is placed in the integer it points to (see  pattern was compiled is placed in the integer it points to (see
756  PCRE_INFO_OPTIONS above).  PCRE_INFO_OPTIONS above).
757    .P
758  If the pattern is not anchored and the \fIfirstcharptr\fR argument is not NULL,  If the pattern is not anchored and the \fIfirstcharptr\fP argument is not NULL,
759  it is used to pass back information about the first character of any matched  it is used to pass back information about the first character of any matched
760  string (see PCRE_INFO_FIRSTBYTE above).  string (see PCRE_INFO_FIRSTBYTE above).
761    .
762  .SH MATCHING A PATTERN  .
763    .SH "MATCHING A PATTERN"
764  .rs  .rs
765  .sp  .sp
766  .B int pcre_exec(const pcre *\fIcode\fR, "const pcre_extra *\fIextra\fR,"  .B int pcre_exec(const pcre *\fIcode\fP, "const pcre_extra *\fIextra\fP,"
767  .ti +5n  .ti +5n
768  .B "const char *\fIsubject\fR," int \fIlength\fR, int \fIstartoffset\fR,  .B "const char *\fIsubject\fP," int \fIlength\fP, int \fIstartoffset\fP,
769  .ti +5n  .ti +5n
770  .B int \fIoptions\fR, int *\fIovector\fR, int \fIovecsize\fR);  .B int \fIoptions\fP, int *\fIovector\fP, int \fIovecsize\fP);
771  .PP  .P
772  The function \fBpcre_exec()\fR is called to match a subject string against a  The function \fBpcre_exec()\fP is called to match a subject string against a
773  pre-compiled pattern, which is passed in the \fIcode\fR argument. If the  compiled pattern, which is passed in the \fIcode\fP argument. If the
774  pattern has been studied, the result of the study should be passed in the  pattern has been studied, the result of the study should be passed in the
775  \fIextra\fR argument.  \fIextra\fP argument.
776    .P
777  Here is an example of a simple call to \fBpcre_exec()\fR:  In most applications, the pattern will have been compiled (and optionally
778    studied) in the same process that calls \fBpcre_exec()\fP. However, it is
779    possible to save compiled patterns and study data, and then use them later
780    in different processes, possibly even on different hosts. For a discussion
781    about this, see the
782    .\" HREF
783    \fBpcreprecompile\fP
784    .\"
785    documentation.
786    .P
787    Here is an example of a simple call to \fBpcre_exec()\fP:
788    .sp
789    int rc;    int rc;
790    int ovector[30];    int ovector[30];
791    rc = pcre_exec(    rc = pcre_exec(
# Line 647  Here is an example of a simple call to \ Line 795  Here is an example of a simple call to \
795      11,             /* the length of the subject string */      11,             /* the length of the subject string */
796      0,              /* start at offset 0 in the subject */      0,              /* start at offset 0 in the subject */
797      0,              /* default options */      0,              /* default options */
798      ovector,        /* vector for substring information */      ovector,        /* vector of integers for substring information */
799      30);            /* number of elements in the vector */      30);            /* number of elements in the vector (NOT size in bytes) */
800    .
801  If the \fIextra\fR argument is not NULL, it must point to a \fBpcre_extra\fR  .\" HTML <a name="extradata"></a>
802  data block. The \fBpcre_study()\fR function returns such a block (when it  .SS "Extra data for \fBpcre_exec()\fR"
803    .rs
804    .sp
805    If the \fIextra\fP argument is not NULL, it must point to a \fBpcre_extra\fP
806    data block. The \fBpcre_study()\fP function returns such a block (when it
807  doesn't return NULL), but you can also create one for yourself, and pass  doesn't return NULL), but you can also create one for yourself, and pass
808  additional information in it. The fields in the block are as follows:  additional information in it. The fields in a \fBpcre_extra\fP block are as
809    follows:
810    unsigned long int \fIflags\fR;  .sp
811    void *\fIstudy_data\fR;    unsigned long int \fIflags\fP;
812    unsigned long int \fImatch_limit\fR;    void *\fIstudy_data\fP;
813    void *\fIcallout_data\fR;    unsigned long int \fImatch_limit\fP;
814      void *\fIcallout_data\fP;
815  The \fIflags\fR field is a bitmap that specifies which of the other fields    const unsigned char *\fItables\fP;
816    .sp
817    The \fIflags\fP field is a bitmap that specifies which of the other fields
818  are set. The flag bits are:  are set. The flag bits are:
819    .sp
820    PCRE_EXTRA_STUDY_DATA    PCRE_EXTRA_STUDY_DATA
821    PCRE_EXTRA_MATCH_LIMIT    PCRE_EXTRA_MATCH_LIMIT
822    PCRE_EXTRA_CALLOUT_DATA    PCRE_EXTRA_CALLOUT_DATA
823      PCRE_EXTRA_TABLES
824  Other flag bits should be set to zero. The \fIstudy_data\fR field is set in the  .sp
825  \fBpcre_extra\fR block that is returned by \fBpcre_study()\fR, together with  Other flag bits should be set to zero. The \fIstudy_data\fP field is set in the
826  the appropriate flag bit. You should not set this yourself, but you can add to  \fBpcre_extra\fP block that is returned by \fBpcre_study()\fP, together with
827  the block by setting the other fields.  the appropriate flag bit. You should not set this yourself, but you may add to
828    the block by setting the other fields and their corresponding flag bits.
829  The \fImatch_limit\fR field provides a means of preventing PCRE from using up a  .P
830    The \fImatch_limit\fP field provides a means of preventing PCRE from using up a
831  vast amount of resources when running patterns that are not going to match,  vast amount of resources when running patterns that are not going to match,
832  but which have a very large number of possibilities in their search trees. The  but which have a very large number of possibilities in their search trees. The
833  classic example is the use of nested unlimited repeats. Internally, PCRE uses a  classic example is the use of nested unlimited repeats.
834  function called \fBmatch()\fR which it calls repeatedly (sometimes  .P
835  recursively). The limit is imposed on the number of times this function is  Internally, PCRE uses a function called \fBmatch()\fP which it calls repeatedly
836  called during a match, which has the effect of limiting the amount of recursion  (sometimes recursively). The limit is imposed on the number of times this
837  and backtracking that can take place. For patterns that are not anchored, the  function is called during a match, which has the effect of limiting the amount
838  count starts from zero for each position in the subject string.  of recursion and backtracking that can take place. For patterns that are not
839    anchored, the count starts from zero for each position in the subject string.
840    .P
841  The default limit for the library can be set when PCRE is built; the default  The default limit for the library can be set when PCRE is built; the default
842  default is 10 million, which handles all but the most extreme cases. You can  default is 10 million, which handles all but the most extreme cases. You can
843  reduce the default by suppling \fBpcre_exec()\fR with a \fRpcre_extra\fR block  reduce the default by suppling \fBpcre_exec()\fP with a \fBpcre_extra\fP block
844  in which \fImatch_limit\fR is set to a smaller value, and  in which \fImatch_limit\fP is set to a smaller value, and
845  PCRE_EXTRA_MATCH_LIMIT is set in the \fIflags\fR field. If the limit is  PCRE_EXTRA_MATCH_LIMIT is set in the \fIflags\fP field. If the limit is
846  exceeded, \fBpcre_exec()\fR returns PCRE_ERROR_MATCHLIMIT.  exceeded, \fBpcre_exec()\fP returns PCRE_ERROR_MATCHLIMIT.
847    .P
848  The \fIpcre_callout\fR field is used in conjunction with the "callout" feature,  The \fIpcre_callout\fP field is used in conjunction with the "callout" feature,
849  which is described in the \fBpcrecallout\fR documentation.  which is described in the
850    .\" HREF
851  The PCRE_ANCHORED option can be passed in the \fIoptions\fR argument, whose  \fBpcrecallout\fP
852  unused bits must be zero. This limits \fBpcre_exec()\fR to matching at the  .\"
853  first matching position. However, if a pattern was compiled with PCRE_ANCHORED,  documentation.
854  or turned out to be anchored by virtue of its contents, it cannot be made  .P
855  unachored at matching time.  The \fItables\fP field is used to pass a character tables pointer to
856    \fBpcre_exec()\fP; this overrides the value that is stored with the compiled
857  There are also three further options that can be set only at matching time:  pattern. A non-NULL value is stored with the compiled pattern only if custom
858    tables were supplied to \fBpcre_compile()\fP via its \fItableptr\fP argument.
859    If NULL is passed to \fBpcre_exec()\fP using this mechanism, it forces PCRE's
860    internal tables to be used. This facility is helpful when re-using patterns
861    that have been saved after compiling with an external set of tables, because
862    the external tables might be at a different address when \fBpcre_exec()\fP is
863    called. See the
864    .\" HREF
865    \fBpcreprecompile\fP
866    .\"
867    documentation for a discussion of saving compiled patterns for later use.
868    .
869    .SS "Option bits for \fBpcre_exec()\fP"
870    .rs
871    .sp
872    The unused bits of the \fIoptions\fP argument for \fBpcre_exec()\fP must be
873    zero. The only bits that may be set are PCRE_ANCHORED, PCRE_NOTBOL,
874    PCRE_NOTEOL, PCRE_NOTEMPTY, PCRE_NO_UTF8_CHECK and PCRE_PARTIAL.
875    .sp
876      PCRE_ANCHORED
877    .sp
878    The PCRE_ANCHORED option limits \fBpcre_exec()\fP to matching at the first
879    matching position. If a pattern was compiled with PCRE_ANCHORED, or turned out
880    to be anchored by virtue of its contents, it cannot be made unachored at
881    matching time.
882    .sp
883    PCRE_NOTBOL    PCRE_NOTBOL
884    .sp
885  The first character of the string is not the beginning of a line, so the  This option specifies that first character of the subject string is not the
886  circumflex metacharacter should not match before it. Setting this without  beginning of a line, so the circumflex metacharacter should not match before
887  PCRE_MULTILINE (at compile time) causes circumflex never to match.  it. Setting this without PCRE_MULTILINE (at compile time) causes circumflex
888    never to match. This option affects only the behaviour of the circumflex
889    metacharacter. It does not affect \eA.
890    .sp
891    PCRE_NOTEOL    PCRE_NOTEOL
892    .sp
893  The end of the string is not the end of a line, so the dollar metacharacter  This option specifies that the end of the subject string is not the end of a
894  should not match it nor (except in multiline mode) a newline immediately before  line, so the dollar metacharacter should not match it nor (except in multiline
895  it. Setting this without PCRE_MULTILINE (at compile time) causes dollar never  mode) a newline immediately before it. Setting this without PCRE_MULTILINE (at
896  to match.  compile time) causes dollar never to match. This option affects only the
897    behaviour of the dollar metacharacter. It does not affect \eZ or \ez.
898    .sp
899    PCRE_NOTEMPTY    PCRE_NOTEMPTY
900    .sp
901  An empty string is not considered to be a valid match if this option is set. If  An empty string is not considered to be a valid match if this option is set. If
902  there are alternatives in the pattern, they are tried. If all the alternatives  there are alternatives in the pattern, they are tried. If all the alternatives
903  match the empty string, the entire match fails. For example, if the pattern  match the empty string, the entire match fails. For example, if the pattern
904    .sp
905    a?b?    a?b?
906    .sp
907  is applied to a string not beginning with "a" or "b", it matches the empty  is applied to a string not beginning with "a" or "b", it matches the empty
908  string at the start of the subject. With PCRE_NOTEMPTY set, this match is not  string at the start of the subject. With PCRE_NOTEMPTY set, this match is not
909  valid, so PCRE searches further into the string for occurrences of "a" or "b".  valid, so PCRE searches further into the string for occurrences of "a" or "b".
910    .P
911  Perl has no direct equivalent of PCRE_NOTEMPTY, but it does make a special case  Perl has no direct equivalent of PCRE_NOTEMPTY, but it does make a special case
912  of a pattern match of the empty string within its \fBsplit()\fR function, and  of a pattern match of the empty string within its \fBsplit()\fP function, and
913  when using the /g modifier. It is possible to emulate Perl's behaviour after  when using the /g modifier. It is possible to emulate Perl's behaviour after
914  matching a null string by first trying the match again at the same offset with  matching a null string by first trying the match again at the same offset with
915  PCRE_NOTEMPTY set, and then if that fails by advancing the starting offset (see  PCRE_NOTEMPTY and PCRE_ANCHORED, and then if that fails by advancing the
916  below) and trying an ordinary match again.  starting offset (see below) and trying an ordinary match again. There is some
917    code that demonstrates how to do this in the \fIpcredemo.c\fP sample program.
918  The subject string is passed to \fBpcre_exec()\fR as a pointer in  .sp
919  \fIsubject\fR, a length in \fIlength\fR, and a starting offset in    PCRE_NO_UTF8_CHECK
920  \fIstartoffset\fR. Unlike the pattern string, the subject may contain binary  .sp
921  zero bytes. When the starting offset is zero, the search for a match starts at  When PCRE_UTF8 is set at compile time, the validity of the subject as a UTF-8
922  the beginning of the subject, and this is by far the most common case.  string is automatically checked when \fBpcre_exec()\fP is subsequently called.
923    The value of \fIstartoffset\fP is also checked to ensure that it points to the
924  If the pattern was compiled with the PCRE_UTF8 option, the subject must be a  start of a UTF-8 character. If an invalid UTF-8 sequence of bytes is found,
925  sequence of bytes that is a valid UTF-8 string. If an invalid UTF-8 string is  \fBpcre_exec()\fP returns the error PCRE_ERROR_BADUTF8. If \fIstartoffset\fP
926  passed, PCRE's behaviour is not defined.  contains an invalid value, PCRE_ERROR_BADUTF8_OFFSET is returned.
927    .P
928    If you already know that your subject is valid, and you want to skip these
929    checks for performance reasons, you can set the PCRE_NO_UTF8_CHECK option when
930    calling \fBpcre_exec()\fP. You might want to do this for the second and
931    subsequent calls to \fBpcre_exec()\fP if you are making repeated calls to find
932    all the matches in a single subject string. However, you should be sure that
933    the value of \fIstartoffset\fP points to the start of a UTF-8 character. When
934    PCRE_NO_UTF8_CHECK is set, the effect of passing an invalid UTF-8 string as a
935    subject, or a value of \fIstartoffset\fP that does not point to the start of a
936    UTF-8 character, is undefined. Your program may crash.
937    .sp
938      PCRE_PARTIAL
939    .sp
940    This option turns on the partial matching feature. If the subject string fails
941    to match the pattern, but at some point during the matching process the end of
942    the subject was reached (that is, the subject partially matches the pattern and
943    the failure to match occurred only because there were not enough subject
944    characters), \fBpcre_exec()\fP returns PCRE_ERROR_PARTIAL instead of
945    PCRE_ERROR_NOMATCH. When PCRE_PARTIAL is used, there are restrictions on what
946    may appear in the pattern. These are discussed in the
947    .\" HREF
948    \fBpcrepartial\fP
949    .\"
950    documentation.
951    .
952    .SS "The string to be matched by \fBpcre_exec()\fP"
953    .rs
954    .sp
955    The subject string is passed to \fBpcre_exec()\fP as a pointer in
956    \fIsubject\fP, a length in \fIlength\fP, and a starting byte offset in
957    \fIstartoffset\fP. In UTF-8 mode, the byte offset must point to the start of a
958    UTF-8 character. Unlike the pattern string, the subject may contain binary zero
959    bytes. When the starting offset is zero, the search for a match starts at the
960    beginning of the subject, and this is by far the most common case.
961    .P
962  A non-zero starting offset is useful when searching for another match in the  A non-zero starting offset is useful when searching for another match in the
963  same subject by calling \fBpcre_exec()\fR again after a previous success.  same subject by calling \fBpcre_exec()\fP again after a previous success.
964  Setting \fIstartoffset\fR differs from just passing over a shortened string and  Setting \fIstartoffset\fP differs from just passing over a shortened string and
965  setting PCRE_NOTBOL in the case of a pattern that begins with any kind of  setting PCRE_NOTBOL in the case of a pattern that begins with any kind of
966  lookbehind. For example, consider the pattern  lookbehind. For example, consider the pattern
967    .sp
968    \\Biss\\B    \eBiss\eB
969    .sp
970  which finds occurrences of "iss" in the middle of words. (\\B matches only if  which finds occurrences of "iss" in the middle of words. (\eB matches only if
971  the current position in the subject is not a word boundary.) When applied to  the current position in the subject is not a word boundary.) When applied to
972  the string "Mississipi" the first call to \fBpcre_exec()\fR finds the first  the string "Mississipi" the first call to \fBpcre_exec()\fP finds the first
973  occurrence. If \fBpcre_exec()\fR is called again with just the remainder of the  occurrence. If \fBpcre_exec()\fP is called again with just the remainder of the
974  subject, namely "issipi", it does not match, because \\B is always false at the  subject, namely "issipi", it does not match, because \eB is always false at the
975  start of the subject, which is deemed to be a word boundary. However, if  start of the subject, which is deemed to be a word boundary. However, if
976  \fBpcre_exec()\fR is passed the entire string again, but with \fIstartoffset\fR  \fBpcre_exec()\fP is passed the entire string again, but with \fIstartoffset\fP
977  set to 4, it finds the second occurrence of "iss" because it is able to look  set to 4, it finds the second occurrence of "iss" because it is able to look
978  behind the starting point to discover that it is preceded by a letter.  behind the starting point to discover that it is preceded by a letter.
979    .P
980  If a non-zero starting offset is passed when the pattern is anchored, one  If a non-zero starting offset is passed when the pattern is anchored, one
981  attempt to match at the given offset is tried. This can only succeed if the  attempt to match at the given offset is made. This can only succeed if the
982  pattern does not require the match to be at the start of the subject.  pattern does not require the match to be at the start of the subject.
983    .
984    .SS "How \fBpcre_exec()\fP returns captured substrings"
985    .rs
986    .sp
987  In general, a pattern matches a certain portion of the subject, and in  In general, a pattern matches a certain portion of the subject, and in
988  addition, further substrings from the subject may be picked out by parts of the  addition, further substrings from the subject may be picked out by parts of the
989  pattern. Following the usage in Jeffrey Friedl's book, this is called  pattern. Following the usage in Jeffrey Friedl's book, this is called
990  "capturing" in what follows, and the phrase "capturing subpattern" is used for  "capturing" in what follows, and the phrase "capturing subpattern" is used for
991  a fragment of a pattern that picks out a substring. PCRE supports several other  a fragment of a pattern that picks out a substring. PCRE supports several other
992  kinds of parenthesized subpattern that do not cause substrings to be captured.  kinds of parenthesized subpattern that do not cause substrings to be captured.
993    .P
994  Captured substrings are returned to the caller via a vector of integer offsets  Captured substrings are returned to the caller via a vector of integer offsets
995  whose address is passed in \fIovector\fR. The number of elements in the vector  whose address is passed in \fIovector\fP. The number of elements in the vector
996  is passed in \fIovecsize\fR. The first two-thirds of the vector is used to pass  is passed in \fIovecsize\fP, which must be a non-negative number. \fBNote\fP:
997  back captured substrings, each substring using a pair of integers. The  this argument is NOT the size of \fIovector\fP in bytes.
998  remaining third of the vector is used as workspace by \fBpcre_exec()\fR while  .P
999  matching capturing subpatterns, and is not available for passing back  The first two-thirds of the vector is used to pass back captured substrings,
1000  information. The length passed in \fIovecsize\fR should always be a multiple of  each substring using a pair of integers. The remaining third of the vector is
1001  three. If it is not, it is rounded down.  used as workspace by \fBpcre_exec()\fP while matching capturing subpatterns,
1002    and is not available for passing back information. The length passed in
1003  When a match has been successful, information about captured substrings is  \fIovecsize\fP should always be a multiple of three. If it is not, it is
1004  returned in pairs of integers, starting at the beginning of \fIovector\fR, and  rounded down.
1005    .P
1006    When a match is successful, information about captured substrings is returned
1007    in pairs of integers, starting at the beginning of \fIovector\fP, and
1008  continuing up to two-thirds of its length at the most. The first element of a  continuing up to two-thirds of its length at the most. The first element of a
1009  pair is set to the offset of the first character in a substring, and the second  pair is set to the offset of the first character in a substring, and the second
1010  is set to the offset of the first character after the end of a substring. The  is set to the offset of the first character after the end of a substring. The
1011  first pair, \fIovector[0]\fR and \fIovector[1]\fR, identify the portion of the  first pair, \fIovector[0]\fP and \fIovector[1]\fP, identify the portion of the
1012  subject string matched by the entire pattern. The next pair is used for the  subject string matched by the entire pattern. The next pair is used for the
1013  first capturing subpattern, and so on. The value returned by \fBpcre_exec()\fR  first capturing subpattern, and so on. The value returned by \fBpcre_exec()\fP
1014  is the number of pairs that have been set. If there are no capturing  is the number of pairs that have been set. If there are no capturing
1015  subpatterns, the return value from a successful match is 1, indicating that  subpatterns, the return value from a successful match is 1, indicating that
1016  just the first pair of offsets has been set.  just the first pair of offsets has been set.
1017    .P
1018  Some convenience functions are provided for extracting the captured substrings  Some convenience functions are provided for extracting the captured substrings
1019  as separate strings. These are described in the following section.  as separate strings. These are described in the following section.
1020    .P
1021  It is possible for an capturing subpattern number \fIn+1\fR to match some  It is possible for an capturing subpattern number \fIn+1\fP to match some
1022  part of the subject when subpattern \fIn\fR has not been used at all. For  part of the subject when subpattern \fIn\fP has not been used at all. For
1023  example, if the string "abc" is matched against the pattern (a|(z))(bc)  example, if the string "abc" is matched against the pattern (a|(z))(bc)
1024  subpatterns 1 and 3 are matched, but 2 is not. When this happens, both offset  subpatterns 1 and 3 are matched, but 2 is not. When this happens, both offset
1025  values corresponding to the unused subpattern are set to -1.  values corresponding to the unused subpattern are set to -1.
1026    .P
1027  If a capturing subpattern is matched repeatedly, it is the last portion of the  If a capturing subpattern is matched repeatedly, it is the last portion of the
1028  string that it matched that gets returned.  string that it matched that is returned.
1029    .P
1030  If the vector is too small to hold all the captured substrings, it is used as  If the vector is too small to hold all the captured substring offsets, it is
1031  far as possible (up to two-thirds of its length), and the function returns a  used as far as possible (up to two-thirds of its length), and the function
1032  value of zero. In particular, if the substring offsets are not of interest,  returns a value of zero. In particular, if the substring offsets are not of
1033  \fBpcre_exec()\fR may be called with \fIovector\fR passed as NULL and  interest, \fBpcre_exec()\fP may be called with \fIovector\fP passed as NULL and
1034  \fIovecsize\fR as zero. However, if the pattern contains back references and  \fIovecsize\fP as zero. However, if the pattern contains back references and
1035  the \fIovector\fR isn't big enough to remember the related substrings, PCRE has  the \fIovector\fP is not big enough to remember the related substrings, PCRE
1036  to get additional memory for use during matching. Thus it is usually advisable  has to get additional memory for use during matching. Thus it is usually
1037  to supply an \fIovector\fR.  advisable to supply an \fIovector\fP.
1038    .P
1039  Note that \fBpcre_info()\fR can be used to find out how many capturing  Note that \fBpcre_info()\fP can be used to find out how many capturing
1040  subpatterns there are in a compiled pattern. The smallest size for  subpatterns there are in a compiled pattern. The smallest size for
1041  \fIovector\fR that will allow for \fIn\fR captured substrings, in addition to  \fIovector\fP that will allow for \fIn\fP captured substrings, in addition to
1042  the offsets of the substring matched by the whole pattern, is (\fIn\fR+1)*3.  the offsets of the substring matched by the whole pattern, is (\fIn\fP+1)*3.
1043    .
1044  If \fBpcre_exec()\fR fails, it returns a negative number. The following are  .SS "Return values from \fBpcre_exec()\fP"
1045    .rs
1046    .sp
1047    If \fBpcre_exec()\fP fails, it returns a negative number. The following are
1048  defined in the header file:  defined in the header file:
1049    .sp
1050    PCRE_ERROR_NOMATCH        (-1)    PCRE_ERROR_NOMATCH        (-1)
1051    .sp
1052  The subject string did not match the pattern.  The subject string did not match the pattern.
1053    .sp
1054    PCRE_ERROR_NULL           (-2)    PCRE_ERROR_NULL           (-2)
1055    .sp
1056  Either \fIcode\fR or \fIsubject\fR was passed as NULL, or \fIovector\fR was  Either \fIcode\fP or \fIsubject\fP was passed as NULL, or \fIovector\fP was
1057  NULL and \fIovecsize\fR was not zero.  NULL and \fIovecsize\fP was not zero.
1058    .sp
1059    PCRE_ERROR_BADOPTION      (-3)    PCRE_ERROR_BADOPTION      (-3)
1060    .sp
1061  An unrecognized bit was set in the \fIoptions\fR argument.  An unrecognized bit was set in the \fIoptions\fP argument.
1062    .sp
1063    PCRE_ERROR_BADMAGIC       (-4)    PCRE_ERROR_BADMAGIC       (-4)
1064    .sp
1065  PCRE stores a 4-byte "magic number" at the start of the compiled code, to catch  PCRE stores a 4-byte "magic number" at the start of the compiled code, to catch
1066  the case when it is passed a junk pointer. This is the error it gives when the  the case when it is passed a junk pointer and to detect when a pattern that was
1067  magic number isn't present.  compiled in an environment of one endianness is run in an environment with the
1068    other endianness. This is the error that PCRE gives when the magic number is
1069    not present.
1070    .sp
1071    PCRE_ERROR_UNKNOWN_NODE   (-5)    PCRE_ERROR_UNKNOWN_NODE   (-5)
1072    .sp
1073  While running the pattern match, an unknown item was encountered in the  While running the pattern match, an unknown item was encountered in the
1074  compiled pattern. This error could be caused by a bug in PCRE or by overwriting  compiled pattern. This error could be caused by a bug in PCRE or by overwriting
1075  of the compiled pattern.  of the compiled pattern.
1076    .sp
1077    PCRE_ERROR_NOMEMORY       (-6)    PCRE_ERROR_NOMEMORY       (-6)
1078    .sp
1079  If a pattern contains back references, but the \fIovector\fR that is passed to  If a pattern contains back references, but the \fIovector\fP that is passed to
1080  \fBpcre_exec()\fR is not big enough to remember the referenced substrings, PCRE  \fBpcre_exec()\fP is not big enough to remember the referenced substrings, PCRE
1081  gets a block of memory at the start of matching to use for this purpose. If the  gets a block of memory at the start of matching to use for this purpose. If the
1082  call via \fBpcre_malloc()\fR fails, this error is given. The memory is freed at  call via \fBpcre_malloc()\fP fails, this error is given. The memory is
1083  the end of matching.  automatically freed at the end of matching.
1084    .sp
1085    PCRE_ERROR_NOSUBSTRING    (-7)    PCRE_ERROR_NOSUBSTRING    (-7)
1086    .sp
1087  This error is used by the \fBpcre_copy_substring()\fR,  This error is used by the \fBpcre_copy_substring()\fP,
1088  \fBpcre_get_substring()\fR, and \fBpcre_get_substring_list()\fR functions (see  \fBpcre_get_substring()\fP, and \fBpcre_get_substring_list()\fP functions (see
1089  below). It is never returned by \fBpcre_exec()\fR.  below). It is never returned by \fBpcre_exec()\fP.
1090    .sp
1091    PCRE_ERROR_MATCHLIMIT     (-8)    PCRE_ERROR_MATCHLIMIT     (-8)
1092    .sp
1093  The recursion and backtracking limit, as specified by the \fImatch_limit\fR  The recursion and backtracking limit, as specified by the \fImatch_limit\fP
1094  field in a \fBpcre_extra\fR structure (or defaulted) was reached. See the  field in a \fBpcre_extra\fP structure (or defaulted) was reached. See the
1095  description above.  description above.
1096    .sp
1097    PCRE_ERROR_CALLOUT        (-9)    PCRE_ERROR_CALLOUT        (-9)
1098    .sp
1099  This error is never generated by \fBpcre_exec()\fR itself. It is provided for  This error is never generated by \fBpcre_exec()\fP itself. It is provided for
1100  use by callout functions that want to yield a distinctive error code. See the  use by callout functions that want to yield a distinctive error code. See the
1101  \fBpcrecallout\fR documentation for details.  .\" HREF
1102    \fBpcrecallout\fP
1103  .SH EXTRACTING CAPTURED SUBSTRINGS BY NUMBER  .\"
1104    documentation for details.
1105    .sp
1106      PCRE_ERROR_BADUTF8        (-10)
1107    .sp
1108    A string that contains an invalid UTF-8 byte sequence was passed as a subject.
1109    .sp
1110      PCRE_ERROR_BADUTF8_OFFSET (-11)
1111    .sp
1112    The UTF-8 byte sequence that was passed as a subject was valid, but the value
1113    of \fIstartoffset\fP did not point to the beginning of a UTF-8 character.
1114    .sp
1115      PCRE_ERROR_PARTIAL (-12)
1116    .sp
1117    The subject string did not match, but it did match partially. See the
1118    .\" HREF
1119    \fBpcrepartial\fP
1120    .\"
1121    documentation for details of partial matching.
1122    .sp
1123      PCRE_ERROR_BAD_PARTIAL (-13)
1124    .sp
1125    The PCRE_PARTIAL option was used with a compiled pattern containing items that
1126    are not supported for partial matching. See the
1127    .\" HREF
1128    \fBpcrepartial\fP
1129    .\"
1130    documentation for details of partial matching.
1131    .sp
1132      PCRE_ERROR_INTERNAL (-14)
1133    .sp
1134    An unexpected internal error has occurred. This error could be caused by a bug
1135    in PCRE or by overwriting of the compiled pattern.
1136    .sp
1137      PCRE_ERROR_BADCOUNT (-15)
1138    .sp
1139    This error is given if the value of the \fIovecsize\fP argument is negative.
1140    .
1141    .
1142    .SH "EXTRACTING CAPTURED SUBSTRINGS BY NUMBER"
1143  .rs  .rs
1144  .sp  .sp
1145  .B int pcre_copy_substring(const char *\fIsubject\fR, int *\fIovector\fR,  .B int pcre_copy_substring(const char *\fIsubject\fP, int *\fIovector\fP,
1146  .ti +5n  .ti +5n
1147  .B int \fIstringcount\fR, int \fIstringnumber\fR, char *\fIbuffer\fR,  .B int \fIstringcount\fP, int \fIstringnumber\fP, char *\fIbuffer\fP,
1148  .ti +5n  .ti +5n
1149  .B int \fIbuffersize\fR);  .B int \fIbuffersize\fP);
1150  .PP  .PP
1151  .br  .br
1152  .B int pcre_get_substring(const char *\fIsubject\fR, int *\fIovector\fR,  .B int pcre_get_substring(const char *\fIsubject\fP, int *\fIovector\fP,
1153  .ti +5n  .ti +5n
1154  .B int \fIstringcount\fR, int \fIstringnumber\fR,  .B int \fIstringcount\fP, int \fIstringnumber\fP,
1155  .ti +5n  .ti +5n
1156  .B const char **\fIstringptr\fR);  .B const char **\fIstringptr\fP);
1157  .PP  .PP
1158  .br  .br
1159  .B int pcre_get_substring_list(const char *\fIsubject\fR,  .B int pcre_get_substring_list(const char *\fIsubject\fP,
1160  .ti +5n  .ti +5n
1161  .B int *\fIovector\fR, int \fIstringcount\fR, "const char ***\fIlistptr\fR);"  .B int *\fIovector\fP, int \fIstringcount\fP, "const char ***\fIlistptr\fP);"
1162  .PP  .PP
1163  Captured substrings can be accessed directly by using the offsets returned by  Captured substrings can be accessed directly by using the offsets returned by
1164  \fBpcre_exec()\fR in \fIovector\fR. For convenience, the functions  \fBpcre_exec()\fP in \fIovector\fP. For convenience, the functions
1165  \fBpcre_copy_substring()\fR, \fBpcre_get_substring()\fR, and  \fBpcre_copy_substring()\fP, \fBpcre_get_substring()\fP, and
1166  \fBpcre_get_substring_list()\fR are provided for extracting captured substrings  \fBpcre_get_substring_list()\fP are provided for extracting captured substrings
1167  as new, separate, zero-terminated strings. These functions identify substrings  as new, separate, zero-terminated strings. These functions identify substrings
1168  by number. The next section describes functions for extracting named  by number. The next section describes functions for extracting named
1169  substrings. A substring that contains a binary zero is correctly extracted and  substrings. A substring that contains a binary zero is correctly extracted and
1170  has a further zero added on the end, but the result is not, of course,  has a further zero added on the end, but the result is not, of course,
1171  a C string.  a C string.
1172    .P
1173  The first three arguments are the same for all three of these functions:  The first three arguments are the same for all three of these functions:
1174  \fIsubject\fR is the subject string which has just been successfully matched,  \fIsubject\fP is the subject string that has just been successfully matched,
1175  \fIovector\fR is a pointer to the vector of integer offsets that was passed to  \fIovector\fP is a pointer to the vector of integer offsets that was passed to
1176  \fBpcre_exec()\fR, and \fIstringcount\fR is the number of substrings that were  \fBpcre_exec()\fP, and \fIstringcount\fP is the number of substrings that were
1177  captured by the match, including the substring that matched the entire regular  captured by the match, including the substring that matched the entire regular
1178  expression. This is the value returned by \fBpcre_exec\fR if it is greater than  expression. This is the value returned by \fBpcre_exec()\fP if it is greater
1179  zero. If \fBpcre_exec()\fR returned zero, indicating that it ran out of space  than zero. If \fBpcre_exec()\fP returned zero, indicating that it ran out of
1180  in \fIovector\fR, the value passed as \fIstringcount\fR should be the size of  space in \fIovector\fP, the value passed as \fIstringcount\fP should be the
1181  the vector divided by three.  number of elements in the vector divided by three.
1182    .P
1183  The functions \fBpcre_copy_substring()\fR and \fBpcre_get_substring()\fR  The functions \fBpcre_copy_substring()\fP and \fBpcre_get_substring()\fP
1184  extract a single substring, whose number is given as \fIstringnumber\fR. A  extract a single substring, whose number is given as \fIstringnumber\fP. A
1185  value of zero extracts the substring that matched the entire pattern, while  value of zero extracts the substring that matched the entire pattern, whereas
1186  higher values extract the captured substrings. For \fBpcre_copy_substring()\fR,  higher values extract the captured substrings. For \fBpcre_copy_substring()\fP,
1187  the string is placed in \fIbuffer\fR, whose length is given by  the string is placed in \fIbuffer\fP, whose length is given by
1188  \fIbuffersize\fR, while for \fBpcre_get_substring()\fR a new block of memory is  \fIbuffersize\fP, while for \fBpcre_get_substring()\fP a new block of memory is
1189  obtained via \fBpcre_malloc\fR, and its address is returned via  obtained via \fBpcre_malloc\fP, and its address is returned via
1190  \fIstringptr\fR. The yield of the function is the length of the string, not  \fIstringptr\fP. The yield of the function is the length of the string, not
1191  including the terminating zero, or one of  including the terminating zero, or one of
1192    .sp
1193    PCRE_ERROR_NOMEMORY       (-6)    PCRE_ERROR_NOMEMORY       (-6)
1194    .sp
1195  The buffer was too small for \fBpcre_copy_substring()\fR, or the attempt to get  The buffer was too small for \fBpcre_copy_substring()\fP, or the attempt to get
1196  memory failed for \fBpcre_get_substring()\fR.  memory failed for \fBpcre_get_substring()\fP.
1197    .sp
1198    PCRE_ERROR_NOSUBSTRING    (-7)    PCRE_ERROR_NOSUBSTRING    (-7)
1199    .sp
1200  There is no substring whose number is \fIstringnumber\fR.  There is no substring whose number is \fIstringnumber\fP.
1201    .P
1202  The \fBpcre_get_substring_list()\fR function extracts all available substrings  The \fBpcre_get_substring_list()\fP function extracts all available substrings
1203  and builds a list of pointers to them. All this is done in a single block of  and builds a list of pointers to them. All this is done in a single block of
1204  memory which is obtained via \fBpcre_malloc\fR. The address of the memory block  memory that is obtained via \fBpcre_malloc\fP. The address of the memory block
1205  is returned via \fIlistptr\fR, which is also the start of the list of string  is returned via \fIlistptr\fP, which is also the start of the list of string
1206  pointers. The end of the list is marked by a NULL pointer. The yield of the  pointers. The end of the list is marked by a NULL pointer. The yield of the
1207  function is zero if all went well, or  function is zero if all went well, or
1208    .sp
1209    PCRE_ERROR_NOMEMORY       (-6)    PCRE_ERROR_NOMEMORY       (-6)
1210    .sp
1211  if the attempt to get the memory block failed.  if the attempt to get the memory block failed.
1212    .P
1213  When any of these functions encounter a substring that is unset, which can  When any of these functions encounter a substring that is unset, which can
1214  happen when capturing subpattern number \fIn+1\fR matches some part of the  happen when capturing subpattern number \fIn+1\fP matches some part of the
1215  subject, but subpattern \fIn\fR has not been used at all, they return an empty  subject, but subpattern \fIn\fP has not been used at all, they return an empty
1216  string. This can be distinguished from a genuine zero-length substring by  string. This can be distinguished from a genuine zero-length substring by
1217  inspecting the appropriate offset in \fIovector\fR, which is negative for unset  inspecting the appropriate offset in \fIovector\fP, which is negative for unset
1218  substrings.  substrings.
1219    .P
1220  The two convenience functions \fBpcre_free_substring()\fR and  The two convenience functions \fBpcre_free_substring()\fP and
1221  \fBpcre_free_substring_list()\fR can be used to free the memory returned by  \fBpcre_free_substring_list()\fP can be used to free the memory returned by
1222  a previous call of \fBpcre_get_substring()\fR or  a previous call of \fBpcre_get_substring()\fP or
1223  \fBpcre_get_substring_list()\fR, respectively. They do nothing more than call  \fBpcre_get_substring_list()\fP, respectively. They do nothing more than call
1224  the function pointed to by \fBpcre_free\fR, which of course could be called  the function pointed to by \fBpcre_free\fP, which of course could be called
1225  directly from a C program. However, PCRE is used in some situations where it is  directly from a C program. However, PCRE is used in some situations where it is
1226  linked via a special interface to another programming language which cannot use  linked via a special interface to another programming language which cannot use
1227  \fBpcre_free\fR directly; it is for these cases that the functions are  \fBpcre_free\fP directly; it is for these cases that the functions are
1228  provided.  provided.
1229    .
1230  .SH EXTRACTING CAPTURED SUBSTRINGS BY NAME  .
1231    .SH "EXTRACTING CAPTURED SUBSTRINGS BY NAME"
1232  .rs  .rs
1233  .sp  .sp
1234  .B int pcre_copy_named_substring(const pcre *\fIcode\fR,  .B int pcre_get_stringnumber(const pcre *\fIcode\fP,
1235  .ti +5n  .ti +5n
1236  .B const char *\fIsubject\fR, int *\fIovector\fR,  .B const char *\fIname\fP);
 .ti +5n  
 .B int \fIstringcount\fR, const char *\fIstringname\fR,  
 .ti +5n  
 .B char *\fIbuffer\fR, int \fIbuffersize\fR);  
1237  .PP  .PP
1238  .br  .br
1239  .B int pcre_get_stringnumber(const pcre *\fIcode\fR,  .B int pcre_copy_named_substring(const pcre *\fIcode\fP,
1240    .ti +5n
1241    .B const char *\fIsubject\fP, int *\fIovector\fP,
1242  .ti +5n  .ti +5n
1243  .B const char *\fIname\fR);  .B int \fIstringcount\fP, const char *\fIstringname\fP,
1244    .ti +5n
1245    .B char *\fIbuffer\fP, int \fIbuffersize\fP);
1246  .PP  .PP
1247  .br  .br
1248  .B int pcre_get_named_substring(const pcre *\fIcode\fR,  .B int pcre_get_named_substring(const pcre *\fIcode\fP,
1249  .ti +5n  .ti +5n
1250  .B const char *\fIsubject\fR, int *\fIovector\fR,  .B const char *\fIsubject\fP, int *\fIovector\fP,
1251  .ti +5n  .ti +5n
1252  .B int \fIstringcount\fR, const char *\fIstringname\fR,  .B int \fIstringcount\fP, const char *\fIstringname\fP,
1253  .ti +5n  .ti +5n
1254  .B const char **\fIstringptr\fR);  .B const char **\fIstringptr\fP);
1255  .PP  .PP
1256  To extract a substring by name, you first have to find associated number. This  To extract a substring by name, you first have to find associated number.
1257  can be done by calling \fBpcre_get_stringnumber()\fR. The first argument is the  For example, for this pattern
1258  compiled pattern, and the second is the name. For example, for this pattern  .sp
1259      (a+)b(?<xxx>\ed+)...
1260    ab(?<xxx>\\d+)...  .sp
1261    the number of the subpattern called "xxx" is 2. You can find the number from
1262  the number of the subpattern called "xxx" is 1. Given the number, you can then  the name by calling \fBpcre_get_stringnumber()\fP. The first argument is the
1263  extract the substring directly, or use one of the functions described in the  compiled pattern, and the second is the name. The yield of the function is the
1264  previous section. For convenience, there are also two functions that do the  subpattern number, or PCRE_ERROR_NOSUBSTRING (-7) if there is no subpattern of
1265  whole job.  that name.
1266    .P
1267  Most of the arguments of \fIpcre_copy_named_substring()\fR and  Given the number, you can extract the substring directly, or use one of the
1268  \fIpcre_get_named_substring()\fR are the same as those for the functions that  functions described in the previous section. For convenience, there are also
1269  extract by number, and so are not re-described here. There are just two  two functions that do the whole job.
1270  differences.  .P
1271    Most of the arguments of \fIpcre_copy_named_substring()\fP and
1272    \fIpcre_get_named_substring()\fP are the same as those for the similarly named
1273    functions that extract by number. As these are described in the previous
1274    section, they are not re-described here. There are just two differences:
1275    .P
1276  First, instead of a substring number, a substring name is given. Second, there  First, instead of a substring number, a substring name is given. Second, there
1277  is an extra argument, given at the start, which is a pointer to the compiled  is an extra argument, given at the start, which is a pointer to the compiled
1278  pattern. This is needed in order to gain access to the name-to-number  pattern. This is needed in order to gain access to the name-to-number
1279  translation table.  translation table.
1280    .P
1281  These functions call \fBpcre_get_stringnumber()\fR, and if it succeeds, they  These functions call \fBpcre_get_stringnumber()\fP, and if it succeeds, they
1282  then call \fIpcre_copy_substring()\fR or \fIpcre_get_substring()\fR, as  then call \fIpcre_copy_substring()\fP or \fIpcre_get_substring()\fP, as
1283  appropriate.  appropriate.
1284    .P
1285  .in 0  .in 0
1286  Last updated: 03 February 2003  Last updated: 09 September 2004
1287  .br  .br
1288  Copyright (c) 1997-2003 University of Cambridge.  Copyright (c) 1997-2004 University of Cambridge.

Legend:
Removed from v.65  
changed lines
  Added in v.75

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12