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 64K code units
14 for the 8-bit and 16-bit libraries if PCRE2 is compiled with the
15 default internal linkage size, which is 2 bytes for these libraries. If
16 you want to process regular expressions that are truly enormous, you
17 can compile PCRE2 with an internal linkage size of 3 or 4 (when buildā
18 ing the 16-bit library, 3 is rounded up to 4). See the README file in
19 the source distribution and the pcre2build documentation for details.
20 In these cases the limit is substantially larger. However, the speed
21 of execution is slower. In the 32-bit library, the internal linkage
22 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 Note that when using the traditional matching function, PCRE2 uses
35 recursion to handle subpatterns and indefinite repetition. This means
36 that the available stack space may limit the size of a subject string
37 that can be processed by certain patterns. For a discussion of stack
38 issues, see the pcre2stack documentation.
39
40 All values in repeating quantifiers must be less than 65536.
41
42 The maximum length of a lookbehind assertion is 65535 characters.
43
44 There is no limit to the number of parenthesized subpatterns, but there
45 can be no more than 65535 capturing subpatterns. There is, however, a
46 limit to the depth of nesting of parenthesized subpatterns of all
47 kinds. This is imposed in order to limit the amount of system stack
48 used at compile time. The default limit can be specified when PCRE2 is
49 built; the default default is 250. An application can change this limit
50 by calling pcre2_set_parens_nest_limit() to set the limit in a compile
51 context.
52
53 The maximum length of name for a named subpattern is 32 code units, and
54 the maximum number of named subpatterns is 10000.
55
56 The maximum length of a name in a (*MARK), (*PRUNE), (*SKIP), or
57 (*THEN) verb is 255 code units for the 8-bit library and 65535 code
58 units for the 16-bit and 32-bit libraries.
59
60 The maximum length of a string argument to a callout is the largest
61 number a 32-bit unsigned integer can hold.
62
64
65 Philip Hazel
66 University Computing Service
67 Cambridge, England.
68
70
71 Last updated: 26 October 2016
72 Copyright (c) 1997-2016 University of Cambridge.
73
74
75
76PCRE2 10.23 26 October 2016 PCRE2LIMITS(3)