blob: 9bf3626db7f36b566267b0463ccd00fa3c805a16 [file] [log] [blame]
Elliott Hughes0c26e192019-08-07 12:24:46 -07001.TH PCRE2LIMITS 3 "03 February 2019" "PCRE2 10.33"
Janis Danisevskis112c9cc2016-03-31 13:35:25 +01002.SH NAME
3PCRE2 - Perl-compatible regular expressions (revised API)
4.SH "SIZE AND OTHER LIMITATIONS"
5.rs
6.sp
7There are some size limitations in PCRE2 but it is hoped that they will never
8in practice be relevant.
9.P
Elliott Hughes653c2102019-01-09 15:41:36 -080010The maximum size of a compiled pattern is approximately 64 thousand code units
11for the 8-bit and 16-bit libraries if PCRE2 is compiled with the default
12internal linkage size, which is 2 bytes for these libraries. If you want to
13process regular expressions that are truly enormous, you can compile PCRE2 with
14an internal linkage size of 3 or 4 (when building the 16-bit library, 3 is
15rounded up to 4). See the \fBREADME\fP file in the source distribution and the
Janis Danisevskis112c9cc2016-03-31 13:35:25 +010016.\" HREF
17\fBpcre2build\fP
18.\"
19documentation for details. In these cases the limit is substantially larger.
20However, the speed of execution is slower. In the 32-bit library, the internal
21linkage size is always 4.
22.P
23The maximum length of a source pattern string is essentially unlimited; it is
24the largest number a PCRE2_SIZE variable can hold. However, the program that
25calls \fBpcre2_compile()\fP can specify a smaller limit.
26.P
27The maximum length (in code units) of a subject string is one less than the
28largest number a PCRE2_SIZE variable can hold. PCRE2_SIZE is an unsigned
29integer type, usually defined as size_t. Its maximum value (that is
30~(PCRE2_SIZE)0) is reserved as a special indicator for zero-terminated strings
31and unset offsets.
32.P
Janis Danisevskis112c9cc2016-03-31 13:35:25 +010033All values in repeating quantifiers must be less than 65536.
34.P
35The maximum length of a lookbehind assertion is 65535 characters.
36.P
Elliott Hughes0c26e192019-08-07 12:24:46 -070037There is no limit to the number of parenthesized groups, but there can be no
38more than 65535 capture groups, and there is a limit to the depth of nesting of
39parenthesized subpatterns of all kinds. This is imposed in order to limit the
40amount of system stack used at compile time. The default limit can be specified
41when PCRE2 is built; if not, the default is set to 250. An application can
42change this limit by calling pcre2_set_parens_nest_limit() to set the limit in
43a compile context.
Janis Danisevskis112c9cc2016-03-31 13:35:25 +010044.P
Elliott Hughes0c26e192019-08-07 12:24:46 -070045The maximum length of name for a named capture group is 32 code units, and the
46maximum number of such groups is 10000.
Janis Danisevskis112c9cc2016-03-31 13:35:25 +010047.P
48The maximum length of a name in a (*MARK), (*PRUNE), (*SKIP), or (*THEN) verb
Elliott Hughes9bc971b2018-07-27 13:23:14 -070049is 255 code units for the 8-bit library and 65535 code units for the 16-bit and
5032-bit libraries.
51.P
52The maximum length of a string argument to a callout is the largest number a
5332-bit unsigned integer can hold.
Janis Danisevskis112c9cc2016-03-31 13:35:25 +010054.
55.
56.SH AUTHOR
57.rs
58.sp
59.nf
60Philip Hazel
61University Computing Service
62Cambridge, England.
63.fi
64.
65.
66.SH REVISION
67.rs
68.sp
69.nf
Elliott Hughes0c26e192019-08-07 12:24:46 -070070Last updated: 02 February 2019
71Copyright (c) 1997-2019 University of Cambridge.
Janis Danisevskis112c9cc2016-03-31 13:35:25 +010072.fi