Home | History | Annotate | Download | only in html
      1 <html>
      2 <head>
      3 <title>pcre2limits specification</title>
      4 </head>
      5 <body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
      6 <h1>pcre2limits man page</h1>
      7 <p>
      8 Return to the <a href="index.html">PCRE2 index page</a>.
      9 </p>
     10 <p>
     11 This page is part of the PCRE2 HTML documentation. It was generated
     12 automatically from the original man page. If there is any nonsense in it,
     13 please consult the man page, in case the conversion went wrong.
     14 <br>
     15 <br><b>
     16 SIZE AND OTHER LIMITATIONS
     17 </b><br>
     18 <P>
     19 There are some size limitations in PCRE2 but it is hoped that they will never
     20 in practice be relevant.
     21 </P>
     22 <P>
     23 The maximum size of a compiled pattern is approximately 64K code units for the
     24 8-bit and 16-bit libraries if PCRE2 is compiled with the default internal
     25 linkage size, which is 2 bytes for these libraries. If you want to process
     26 regular expressions that are truly enormous, you can compile PCRE2 with an
     27 internal linkage size of 3 or 4 (when building the 16-bit library, 3 is rounded
     28 up to 4). See the <b>README</b> file in the source distribution and the
     29 <a href="pcre2build.html"><b>pcre2build</b></a>
     30 documentation for details. In these cases the limit is substantially larger.
     31 However, the speed of execution is slower. In the 32-bit library, the internal
     32 linkage size is always 4.
     33 </P>
     34 <P>
     35 The maximum length of a source pattern string is essentially unlimited; it is
     36 the largest number a PCRE2_SIZE variable can hold. However, the program that
     37 calls <b>pcre2_compile()</b> can specify a smaller limit.
     38 </P>
     39 <P>
     40 The maximum length (in code units) of a subject string is one less than the
     41 largest number a PCRE2_SIZE variable can hold. PCRE2_SIZE is an unsigned
     42 integer type, usually defined as size_t. Its maximum value (that is
     43 ~(PCRE2_SIZE)0) is reserved as a special indicator for zero-terminated strings
     44 and unset offsets.
     45 </P>
     46 <P>
     47 Note that when using the traditional matching function, PCRE2 uses recursion to
     48 handle subpatterns and indefinite repetition. This means that the available
     49 stack space may limit the size of a subject string that can be processed by
     50 certain patterns. For a discussion of stack issues, see the
     51 <a href="pcre2stack.html"><b>pcre2stack</b></a>
     52 documentation.
     53 </P>
     54 <P>
     55 All values in repeating quantifiers must be less than 65536.
     56 </P>
     57 <P>
     58 The maximum length of a lookbehind assertion is 65535 characters.
     59 </P>
     60 <P>
     61 There is no limit to the number of parenthesized subpatterns, but there can be
     62 no more than 65535 capturing subpatterns. There is, however, a limit to the
     63 depth of nesting of parenthesized subpatterns of all kinds. This is imposed in
     64 order to limit the amount of system stack used at compile time. The limit can
     65 be specified when PCRE2 is built; the default is 250.
     66 </P>
     67 <P>
     68 There is a limit to the number of forward references to subsequent subpatterns
     69 of around 200,000. Repeated forward references with fixed upper limits, for
     70 example, (?2){0,100} when subpattern number 2 is to the right, are included in
     71 the count. There is no limit to the number of backward references.
     72 </P>
     73 <P>
     74 The maximum length of name for a named subpattern is 32 code units, and the
     75 maximum number of named subpatterns is 10000.
     76 </P>
     77 <P>
     78 The maximum length of a name in a (*MARK), (*PRUNE), (*SKIP), or (*THEN) verb
     79 is 255 for the 8-bit library and 65535 for the 16-bit and 32-bit libraries.
     80 </P>
     81 <br><b>
     82 AUTHOR
     83 </b><br>
     84 <P>
     85 Philip Hazel
     86 <br>
     87 University Computing Service
     88 <br>
     89 Cambridge, England.
     90 <br>
     91 </P>
     92 <br><b>
     93 REVISION
     94 </b><br>
     95 <P>
     96 Last updated: 05 November 2015
     97 <br>
     98 Copyright &copy; 1997-2015 University of Cambridge.
     99 <br>
    100 <p>
    101 Return to the <a href="index.html">PCRE2 index page</a>.
    102 </p>
    103