chiark / gitweb /
more quilt faff
[pcre3.git] / doc / pcre_compile2.3
1 .TH PCRE_COMPILE2 3 "01 October 2013" "PCRE 8.34"
2 .SH NAME
3 PCRE - Perl-compatible regular expressions
4 .SH SYNOPSIS
5 .rs
6 .sp
7 .B #include <pcre.h>
8 .PP
9 .nf
10 .B pcre *pcre_compile2(const char *\fIpattern\fP, int \fIoptions\fP,
11 .B "     int *\fIerrorcodeptr\fP,"
12 .B "     const char **\fIerrptr\fP, int *\fIerroffset\fP,"
13 .B "     const unsigned char *\fItableptr\fP);"
14 .sp
15 .B pcre16 *pcre16_compile2(PCRE_SPTR16 \fIpattern\fP, int \fIoptions\fP,
16 .B "     int *\fIerrorcodeptr\fP,"
17 .B "     const char **\fIerrptr\fP, int *\fIerroffset\fP,"
18 .B "     const unsigned char *\fItableptr\fP);"
19 .sp
20 .B pcre32 *pcre32_compile2(PCRE_SPTR32 \fIpattern\fP, int \fIoptions\fP,
21 .B "     int *\fIerrorcodeptr\fP,£
22 .B "     const char **\fIerrptr\fP, int *\fIerroffset\fP,"
23 .B "     const unsigned char *\fItableptr\fP);"
24 .fi
25 .
26 .SH DESCRIPTION
27 .rs
28 .sp
29 This function compiles a regular expression into an internal form. It is the
30 same as \fBpcre[16|32]_compile()\fP, except for the addition of the
31 \fIerrorcodeptr\fP argument. The arguments are:
32 .
33 .sp
34   \fIpattern\fP       A zero-terminated string containing the
35                   regular expression to be compiled
36   \fIoptions\fP       Zero or more option bits
37   \fIerrorcodeptr\fP  Where to put an error code
38   \fIerrptr\fP        Where to put an error message
39   \fIerroffset\fP     Offset in pattern where error was found
40   \fItableptr\fP      Pointer to character tables, or NULL to
41                   use the built-in default
42 .sp
43 The option bits are:
44 .sp
45   PCRE_ANCHORED           Force pattern anchoring
46   PCRE_AUTO_CALLOUT       Compile automatic callouts
47   PCRE_BSR_ANYCRLF        \eR matches only CR, LF, or CRLF
48   PCRE_BSR_UNICODE        \eR matches all Unicode line endings
49   PCRE_CASELESS           Do caseless matching
50   PCRE_DOLLAR_ENDONLY     $ not to match newline at end
51   PCRE_DOTALL             . matches anything including NL
52   PCRE_DUPNAMES           Allow duplicate names for subpatterns
53   PCRE_EXTENDED           Ignore white space and # comments
54   PCRE_EXTRA              PCRE extra features
55                             (not much use currently)
56   PCRE_FIRSTLINE          Force matching to be before newline
57   PCRE_JAVASCRIPT_COMPAT  JavaScript compatibility
58   PCRE_MULTILINE          ^ and $ match newlines within data
59   PCRE_NEVER_UTF          Lock out UTF, e.g. via (*UTF)
60   PCRE_NEWLINE_ANY        Recognize any Unicode newline sequence
61   PCRE_NEWLINE_ANYCRLF    Recognize CR, LF, and CRLF as newline
62                             sequences
63   PCRE_NEWLINE_CR         Set CR as the newline sequence
64   PCRE_NEWLINE_CRLF       Set CRLF as the newline sequence
65   PCRE_NEWLINE_LF         Set LF as the newline sequence
66   PCRE_NO_AUTO_CAPTURE    Disable numbered capturing paren-
67                             theses (named ones available)
68   PCRE_NO_AUTO_POSSESS    Disable auto-possessification
69   PCRE_NO_START_OPTIMIZE  Disable match-time start optimizations
70   PCRE_NO_UTF16_CHECK     Do not check the pattern for UTF-16
71                             validity (only relevant if
72                             PCRE_UTF16 is set)
73   PCRE_NO_UTF32_CHECK     Do not check the pattern for UTF-32
74                             validity (only relevant if
75                             PCRE_UTF32 is set)
76   PCRE_NO_UTF8_CHECK      Do not check the pattern for UTF-8
77                             validity (only relevant if
78                             PCRE_UTF8 is set)
79   PCRE_UCP                Use Unicode properties for \ed, \ew, etc.
80   PCRE_UNGREEDY           Invert greediness of quantifiers
81   PCRE_UTF16              Run \fBpcre16_compile()\fP in UTF-16 mode
82   PCRE_UTF32              Run \fBpcre32_compile()\fP in UTF-32 mode
83   PCRE_UTF8               Run \fBpcre_compile()\fP in UTF-8 mode
84 .sp
85 PCRE must be built with UTF support in order to use PCRE_UTF8/16/32 and
86 PCRE_NO_UTF8/16/32_CHECK, and with UCP support if PCRE_UCP is used.
87 .P
88 The yield of the function is a pointer to a private data structure that
89 contains the compiled pattern, or NULL if an error was detected. Note that
90 compiling regular expressions with one version of PCRE for use with a different
91 version is not guaranteed to work and may cause crashes.
92 .P
93 There is a complete description of the PCRE native API in the
94 .\" HREF
95 \fBpcreapi\fP
96 .\"
97 page and a description of the POSIX API in the
98 .\" HREF
99 \fBpcreposix\fP
100 .\"
101 page.