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 li‐
16 braries. 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 in‐
22 ternal 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 un‐
30 signed integer type, usually defined as size_t. Its maximum value (that
31 is ~(PCRE2_SIZE)0) is reserved as a special indicator for zero-termi‐
32 nated 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
56 The maximum amount of heap memory used for matching is controlled by
57 the heap limit, which can be set in a pattern or in a match context.
58 The default is a very large number, effectively unlimited.
59
61
62 Philip Hazel
63 Retired from University Computing Service
64 Cambridge, England.
65
67
68 Last updated: 26 July 2022
69 Copyright (c) 1997-2022 University of Cambridge.
70
71
72
73PCRE2 10.41 26 July 2022 PCRE2LIMITS(3)