Janis Danisevskis | 112c9cc | 2016-03-31 13:35:25 +0100 | [diff] [blame^] | 1 | .TH PCRE2LIMITS 3 "05 November 2015" "PCRE2 10.21" |
| 2 | .SH NAME |
| 3 | PCRE2 - Perl-compatible regular expressions (revised API) |
| 4 | .SH "SIZE AND OTHER LIMITATIONS" |
| 5 | .rs |
| 6 | .sp |
| 7 | There are some size limitations in PCRE2 but it is hoped that they will never |
| 8 | in practice be relevant. |
| 9 | .P |
| 10 | The maximum size of a compiled pattern is approximately 64K code units for the |
| 11 | 8-bit and 16-bit libraries if PCRE2 is compiled with the default internal |
| 12 | linkage size, which is 2 bytes for these libraries. If you want to process |
| 13 | regular expressions that are truly enormous, you can compile PCRE2 with an |
| 14 | internal linkage size of 3 or 4 (when building the 16-bit library, 3 is rounded |
| 15 | up to 4). See the \fBREADME\fP file in the source distribution and the |
| 16 | .\" HREF |
| 17 | \fBpcre2build\fP |
| 18 | .\" |
| 19 | documentation for details. In these cases the limit is substantially larger. |
| 20 | However, the speed of execution is slower. In the 32-bit library, the internal |
| 21 | linkage size is always 4. |
| 22 | .P |
| 23 | The maximum length of a source pattern string is essentially unlimited; it is |
| 24 | the largest number a PCRE2_SIZE variable can hold. However, the program that |
| 25 | calls \fBpcre2_compile()\fP can specify a smaller limit. |
| 26 | .P |
| 27 | The maximum length (in code units) of a subject string is one less than the |
| 28 | largest number a PCRE2_SIZE variable can hold. PCRE2_SIZE is an unsigned |
| 29 | integer 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 |
| 31 | and unset offsets. |
| 32 | .P |
| 33 | Note that when using the traditional matching function, PCRE2 uses recursion to |
| 34 | handle subpatterns and indefinite repetition. This means that the available |
| 35 | stack space may limit the size of a subject string that can be processed by |
| 36 | certain patterns. For a discussion of stack issues, see the |
| 37 | .\" HREF |
| 38 | \fBpcre2stack\fP |
| 39 | .\" |
| 40 | documentation. |
| 41 | .P |
| 42 | All values in repeating quantifiers must be less than 65536. |
| 43 | .P |
| 44 | The maximum length of a lookbehind assertion is 65535 characters. |
| 45 | .P |
| 46 | There is no limit to the number of parenthesized subpatterns, but there can be |
| 47 | no more than 65535 capturing subpatterns. There is, however, a limit to the |
| 48 | depth of nesting of parenthesized subpatterns of all kinds. This is imposed in |
| 49 | order to limit the amount of system stack used at compile time. The limit can |
| 50 | be specified when PCRE2 is built; the default is 250. |
| 51 | .P |
| 52 | There is a limit to the number of forward references to subsequent subpatterns |
| 53 | of around 200,000. Repeated forward references with fixed upper limits, for |
| 54 | example, (?2){0,100} when subpattern number 2 is to the right, are included in |
| 55 | the count. There is no limit to the number of backward references. |
| 56 | .P |
| 57 | The maximum length of name for a named subpattern is 32 code units, and the |
| 58 | maximum number of named subpatterns is 10000. |
| 59 | .P |
| 60 | The maximum length of a name in a (*MARK), (*PRUNE), (*SKIP), or (*THEN) verb |
| 61 | is 255 for the 8-bit library and 65535 for the 16-bit and 32-bit libraries. |
| 62 | . |
| 63 | . |
| 64 | .SH AUTHOR |
| 65 | .rs |
| 66 | .sp |
| 67 | .nf |
| 68 | Philip Hazel |
| 69 | University Computing Service |
| 70 | Cambridge, England. |
| 71 | .fi |
| 72 | . |
| 73 | . |
| 74 | .SH REVISION |
| 75 | .rs |
| 76 | .sp |
| 77 | .nf |
| 78 | Last updated: 05 November 2015 |
| 79 | Copyright (c) 1997-2015 University of Cambridge. |
| 80 | .fi |