• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<title>pcre2_compile specification</title>
4</head>
5<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
6<h1>pcre2_compile man page</h1>
7<p>
8Return to the <a href="index.html">PCRE2 index page</a>.
9</p>
10<p>
11This page is part of the PCRE2 HTML documentation. It was generated
12automatically from the original man page. If there is any nonsense in it,
13please consult the man page, in case the conversion went wrong.
14<br>
15<br><b>
16SYNOPSIS
17</b><br>
18<P>
19<b>#include &#60;pcre2.h&#62;</b>
20</P>
21<P>
22<b>pcre2_code *pcre2_compile(PCRE2_SPTR <i>pattern</i>, PCRE2_SIZE <i>length</i>,</b>
23<b>  uint32_t <i>options</i>, int *<i>errorcode</i>, PCRE2_SIZE *<i>erroroffset,</i></b>
24<b>  pcre2_compile_context *<i>ccontext</i>);</b>
25</P>
26<br><b>
27DESCRIPTION
28</b><br>
29<P>
30This function compiles a regular expression pattern into an internal form. Its
31arguments are:
32<pre>
33  <i>pattern</i>       A string containing expression to be compiled
34  <i>length</i>        The length of the string or PCRE2_ZERO_TERMINATED
35  <i>options</i>       Option bits
36  <i>errorcode</i>     Where to put an error code
37  <i>erroffset</i>     Where to put an error offset
38  <i>ccontext</i>      Pointer to a compile context or NULL
39</pre>
40The length of the pattern and any error offset that is returned are in code
41units, not characters. A compile context is needed only if you want to provide
42custom memory allocation functions, or to provide an external function for
43system stack size checking, or to change one or more of these parameters:
44<pre>
45  What \R matches (Unicode newlines, or CR, LF, CRLF only);
46  PCRE2's character tables;
47  The newline character sequence;
48  The compile time nested parentheses limit;
49  The maximum pattern length (in code units) that is allowed.
50  The additional options bits (see pcre2_set_compile_extra_options())
51</pre>
52The option bits are:
53<pre>
54  PCRE2_ANCHORED           Force pattern anchoring
55  PCRE2_ALLOW_EMPTY_CLASS  Allow empty classes
56  PCRE2_ALT_BSUX           Alternative handling of \u, \U, and \x
57  PCRE2_ALT_CIRCUMFLEX     Alternative handling of ^ in multiline mode
58  PCRE2_ALT_VERBNAMES      Process backslashes in verb names
59  PCRE2_AUTO_CALLOUT       Compile automatic callouts
60  PCRE2_CASELESS           Do caseless matching
61  PCRE2_DOLLAR_ENDONLY     $ not to match newline at end
62  PCRE2_DOTALL             . matches anything including NL
63  PCRE2_DUPNAMES           Allow duplicate names for subpatterns
64  PCRE2_ENDANCHORED        Pattern can match only at end of subject
65  PCRE2_EXTENDED           Ignore white space and # comments
66  PCRE2_FIRSTLINE          Force matching to be before newline
67  PCRE2_LITERAL            Pattern characters are all literal
68  PCRE2_MATCH_INVALID_UTF  Enable support for matching invalid UTF
69  PCRE2_MATCH_UNSET_BACKREF  Match unset backreferences
70  PCRE2_MULTILINE          ^ and $ match newlines within data
71  PCRE2_NEVER_BACKSLASH_C  Lock out the use of \C in patterns
72  PCRE2_NEVER_UCP          Lock out PCRE2_UCP, e.g. via (*UCP)
73  PCRE2_NEVER_UTF          Lock out PCRE2_UTF, e.g. via (*UTF)
74  PCRE2_NO_AUTO_CAPTURE    Disable numbered capturing paren-
75                            theses (named ones available)
76  PCRE2_NO_AUTO_POSSESS    Disable auto-possessification
77  PCRE2_NO_DOTSTAR_ANCHOR  Disable automatic anchoring for .*
78  PCRE2_NO_START_OPTIMIZE  Disable match-time start optimizations
79  PCRE2_NO_UTF_CHECK       Do not check the pattern for UTF validity
80                             (only relevant if PCRE2_UTF is set)
81  PCRE2_UCP                Use Unicode properties for \d, \w, etc.
82  PCRE2_UNGREEDY           Invert greediness of quantifiers
83  PCRE2_USE_OFFSET_LIMIT   Enable offset limit for unanchored matching
84  PCRE2_UTF                Treat pattern and subjects as UTF strings
85</pre>
86PCRE2 must be built with Unicode support (the default) in order to use
87PCRE2_UTF, PCRE2_UCP and related options.
88</P>
89<P>
90Additional options may be set in the compile context via the
91<a href="pcre2_set_compile_extra_options.html"><b>pcre2_set_compile_extra_options</b></a>
92function.
93</P>
94<P>
95The yield of this function is a pointer to a private data structure that
96contains the compiled pattern, or NULL if an error was detected.
97</P>
98<P>
99There is a complete description of the PCRE2 native API, with more detail on
100each option, in the
101<a href="pcre2api.html"><b>pcre2api</b></a>
102page, and a description of the POSIX API in the
103<a href="pcre2posix.html"><b>pcre2posix</b></a>
104page.
105<p>
106Return to the <a href="index.html">PCRE2 index page</a>.
107</p>
108