1PCRE2_COMPILE(3)           Library Functions Manual           PCRE2_COMPILE(3)
2
3
4

NAME

6       PCRE2 - Perl-compatible regular expressions (revised API)
7

SYNOPSIS

9
10       #include <pcre2.h>
11
12       pcre2_code *pcre2_compile(PCRE2_SPTR pattern, PCRE2_SIZE length,
13         uint32_t options, int *errorcode, PCRE2_SIZE *erroroffset,
14         pcre2_compile_context *ccontext);
15

DESCRIPTION

17
18       This  function  compiles  a regular expression pattern into an internal
19       form. Its arguments are:
20
21         pattern       A string containing expression to be compiled
22         length        The length of the string or PCRE2_ZERO_TERMINATED
23         options       Option bits
24         errorcode     Where to put an error code
25         erroffset     Where to put an error offset
26         ccontext      Pointer to a compile context or NULL
27
28       The length of the pattern and any error offset that is returned are  in
29       code  units,  not  characters.  A compile context is needed only if you
30       want to provide custom memory allocation functions, or  to  provide  an
31       external  function  for system stack size checking, or to change one or
32       more of these parameters:
33
34         What \R matches (Unicode newlines, or CR, LF, CRLF only);
35         PCRE2's character tables;
36         The newline character sequence;
37         The compile time nested parentheses limit;
38         The maximum pattern length (in code units) that is allowed.
39         The additional options bits (see pcre2_set_compile_extra_options())
40
41       The option bits are:
42
43         PCRE2_ANCHORED           Force pattern anchoring
44         PCRE2_ALLOW_EMPTY_CLASS  Allow empty classes
45         PCRE2_ALT_BSUX           Alternative handling of \u, \U, and \x
46         PCRE2_ALT_CIRCUMFLEX     Alternative handling of ^ in multiline mode
47         PCRE2_ALT_VERBNAMES      Process backslashes in verb names
48         PCRE2_AUTO_CALLOUT       Compile automatic callouts
49         PCRE2_CASELESS           Do caseless matching
50         PCRE2_DOLLAR_ENDONLY     $ not to match newline at end
51         PCRE2_DOTALL             . matches anything including NL
52         PCRE2_DUPNAMES           Allow duplicate names for subpatterns
53         PCRE2_ENDANCHORED        Pattern can match only at end of subject
54         PCRE2_EXTENDED           Ignore white space and # comments
55         PCRE2_FIRSTLINE          Force matching to be before newline
56         PCRE2_LITERAL            Pattern characters are all literal
57         PCRE2_MATCH_INVALID_UTF  Enable support for matching invalid UTF
58         PCRE2_MATCH_UNSET_BACKREF  Match unset backreferences
59         PCRE2_MULTILINE          ^ and $ match newlines within data
60         PCRE2_NEVER_BACKSLASH_C  Lock out the use of \C in patterns
61         PCRE2_NEVER_UCP          Lock out PCRE2_UCP, e.g. via (*UCP)
62         PCRE2_NEVER_UTF          Lock out PCRE2_UTF, e.g. via (*UTF)
63         PCRE2_NO_AUTO_CAPTURE    Disable numbered capturing paren-
64                                   theses (named ones available)
65         PCRE2_NO_AUTO_POSSESS    Disable auto-possessification
66         PCRE2_NO_DOTSTAR_ANCHOR  Disable automatic anchoring for .*
67         PCRE2_NO_START_OPTIMIZE  Disable match-time start optimizations
68         PCRE2_NO_UTF_CHECK       Do not check the pattern for UTF validity
69                                    (only relevant if PCRE2_UTF is set)
70         PCRE2_UCP                Use Unicode properties for \d, \w, etc.
71         PCRE2_UNGREEDY           Invert greediness of quantifiers
72         PCRE2_USE_OFFSET_LIMIT   Enable offset limit for unanchored matching
73         PCRE2_UTF                Treat pattern and subjects as UTF strings
74
75       PCRE2 must be built with Unicode support (the default) in order to  use
76       PCRE2_UTF, PCRE2_UCP and related options.
77
78       Additional   options  may  be  set  in  the  compile  context  via  the
79       pcre2_set_compile_extra_options function.
80
81       If either of errorcode or erroroffset is  NULL,  the  function  returns
82       NULL immediately. Otherwise, the yield of this function is a pointer to
83       a private data structure that contains the compiled pattern, or NULL if
84       an  error  was detected. In the error case, a text error message can be
85       obtained by passing the value returned via the  errorcode  argument  to
86       the  the pcre2_get_error_message() function. The offset (in code units)
87       where the error was encountered is returned via the  erroroffset  argu‐
88       ment.
89
90       If  there  is no error, the value passed via errorcode returns the mes‐
91       sage "no error" if passed to pcre2_get_error_message(), and  the  value
92       passed via erroroffset is zero.
93
94       There  is a complete description of the PCRE2 native API, with more de‐
95       tail on each option, in the pcre2api page, and  a  description  of  the
96       POSIX API in the pcre2posix page.
97
98
99
100PCRE2 10.41                      22 April 2022                PCRE2_COMPILE(3)
Impressum