1PCRE2LIMITS(3) Library Functions Manual PCRE2LIMITS(3)
2
3
4
6 PCRE2 - Perl-compatible regular expressions (revised API)
7
9
10 There are some size limitations in PCRE2 but it is hoped that they will
11 never in practice be relevant.
12
13 The maximum size of a compiled pattern is approximately 64 thousand
14 code units for the 8-bit and 16-bit libraries if PCRE2 is compiled with
15 the default internal linkage size, which is 2 bytes for these
16 libraries. If you want to process regular expressions that are truly
17 enormous, you can compile PCRE2 with an internal linkage size of 3 or 4
18 (when building the 16-bit library, 3 is rounded up to 4). See the
19 README file in the source distribution and the pcre2build documentation
20 for details. In these cases the limit is substantially larger. How‐
21 ever, the speed of execution is slower. In the 32-bit library, the
22 internal linkage size is always 4.
23
24 The maximum length of a source pattern string is essentially unlimited;
25 it is the largest number a PCRE2_SIZE variable can hold. However, the
26 program that calls pcre2_compile() can specify a smaller limit.
27
28 The maximum length (in code units) of a subject string is one less than
29 the largest number a PCRE2_SIZE variable can hold. PCRE2_SIZE is an
30 unsigned integer type, usually defined as size_t. Its maximum value
31 (that is ~(PCRE2_SIZE)0) is reserved as a special indicator for zero-
32 terminated strings and unset offsets.
33
34 All values in repeating quantifiers must be less than 65536.
35
36 The maximum length of a lookbehind assertion is 65535 characters.
37
38 There is no limit to the number of parenthesized groups, but there can
39 be no more than 65535 capture groups, and there is a limit to the depth
40 of nesting of parenthesized subpatterns of all kinds. This is imposed
41 in order to limit the amount of system stack used at compile time. The
42 default limit can be specified when PCRE2 is built; if not, the default
43 is set to 250. An application can change this limit by calling
44 pcre2_set_parens_nest_limit() to set the limit in a compile context.
45
46 The maximum length of name for a named capture group is 32 code units,
47 and the maximum number of such groups is 10000.
48
49 The maximum length of a name in a (*MARK), (*PRUNE), (*SKIP), or
50 (*THEN) verb is 255 code units for the 8-bit library and 65535 code
51 units for the 16-bit and 32-bit libraries.
52
53 The maximum length of a string argument to a callout is the largest
54 number a 32-bit unsigned integer can hold.
55
57
58 Philip Hazel
59 University Computing Service
60 Cambridge, England.
61
63
64 Last updated: 02 February 2019
65 Copyright (c) 1997-2019 University of Cambridge.
66
67
68
69PCRE2 10.33 03 February 2019 PCRE2LIMITS(3)