1*22dc650dSSadaf Ebrahimi<html> 2*22dc650dSSadaf Ebrahimi<head> 3*22dc650dSSadaf Ebrahimi<title>pcre2limits specification</title> 4*22dc650dSSadaf Ebrahimi</head> 5*22dc650dSSadaf Ebrahimi<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB"> 6*22dc650dSSadaf Ebrahimi<h1>pcre2limits man page</h1> 7*22dc650dSSadaf Ebrahimi<p> 8*22dc650dSSadaf EbrahimiReturn to the <a href="index.html">PCRE2 index page</a>. 9*22dc650dSSadaf Ebrahimi</p> 10*22dc650dSSadaf Ebrahimi<p> 11*22dc650dSSadaf EbrahimiThis page is part of the PCRE2 HTML documentation. It was generated 12*22dc650dSSadaf Ebrahimiautomatically from the original man page. If there is any nonsense in it, 13*22dc650dSSadaf Ebrahimiplease consult the man page, in case the conversion went wrong. 14*22dc650dSSadaf Ebrahimi<br> 15*22dc650dSSadaf Ebrahimi<br><b> 16*22dc650dSSadaf EbrahimiSIZE AND OTHER LIMITATIONS 17*22dc650dSSadaf Ebrahimi</b><br> 18*22dc650dSSadaf Ebrahimi<P> 19*22dc650dSSadaf EbrahimiThere are some size limitations in PCRE2 but it is hoped that they will never 20*22dc650dSSadaf Ebrahimiin practice be relevant. 21*22dc650dSSadaf Ebrahimi</P> 22*22dc650dSSadaf Ebrahimi<P> 23*22dc650dSSadaf EbrahimiThe maximum size of a compiled pattern is approximately 64 thousand code units 24*22dc650dSSadaf Ebrahimifor the 8-bit and 16-bit libraries if PCRE2 is compiled with the default 25*22dc650dSSadaf Ebrahimiinternal linkage size, which is 2 bytes for these libraries. If you want to 26*22dc650dSSadaf Ebrahimiprocess regular expressions that are truly enormous, you can compile PCRE2 with 27*22dc650dSSadaf Ebrahimian internal linkage size of 3 or 4 (when building the 16-bit library, 3 is 28*22dc650dSSadaf Ebrahimirounded up to 4). See the <b>README</b> file in the source distribution and the 29*22dc650dSSadaf Ebrahimi<a href="pcre2build.html"><b>pcre2build</b></a> 30*22dc650dSSadaf Ebrahimidocumentation for details. In these cases the limit is substantially larger. 31*22dc650dSSadaf EbrahimiHowever, the speed of execution is slower. In the 32-bit library, the internal 32*22dc650dSSadaf Ebrahimilinkage size is always 4. 33*22dc650dSSadaf Ebrahimi</P> 34*22dc650dSSadaf Ebrahimi<P> 35*22dc650dSSadaf EbrahimiThe maximum length of a source pattern string is essentially unlimited; it is 36*22dc650dSSadaf Ebrahimithe largest number a PCRE2_SIZE variable can hold. However, the program that 37*22dc650dSSadaf Ebrahimicalls <b>pcre2_compile()</b> can specify a smaller limit. 38*22dc650dSSadaf Ebrahimi</P> 39*22dc650dSSadaf Ebrahimi<P> 40*22dc650dSSadaf EbrahimiThe maximum length (in code units) of a subject string is one less than the 41*22dc650dSSadaf Ebrahimilargest number a PCRE2_SIZE variable can hold. PCRE2_SIZE is an unsigned 42*22dc650dSSadaf Ebrahimiinteger type, usually defined as size_t. Its maximum value (that is 43*22dc650dSSadaf Ebrahimi~(PCRE2_SIZE)0) is reserved as a special indicator for zero-terminated strings 44*22dc650dSSadaf Ebrahimiand unset offsets. 45*22dc650dSSadaf Ebrahimi</P> 46*22dc650dSSadaf Ebrahimi<P> 47*22dc650dSSadaf EbrahimiAll values in repeating quantifiers must be less than 65536. 48*22dc650dSSadaf Ebrahimi</P> 49*22dc650dSSadaf Ebrahimi<P> 50*22dc650dSSadaf EbrahimiThere are two different limits that apply to branches of lookbehind assertions. 51*22dc650dSSadaf EbrahimiIf every branch in such an assertion matches a fixed number of characters, 52*22dc650dSSadaf Ebrahimithe maximum length of any branch is 65535 characters. If any branch matches a 53*22dc650dSSadaf Ebrahimivariable number of characters, then the maximum matching length for every 54*22dc650dSSadaf Ebrahimibranch is limited. The default limit is set at compile time, defaulting to 255, 55*22dc650dSSadaf Ebrahimibut can be changed by the calling program. 56*22dc650dSSadaf Ebrahimi</P> 57*22dc650dSSadaf Ebrahimi<P> 58*22dc650dSSadaf EbrahimiThere is no limit to the number of parenthesized groups, but there can be no 59*22dc650dSSadaf Ebrahimimore than 65535 capture groups, and there is a limit to the depth of nesting of 60*22dc650dSSadaf Ebrahimiparenthesized subpatterns of all kinds. This is imposed in order to limit the 61*22dc650dSSadaf Ebrahimiamount of system stack used at compile time. The default limit can be specified 62*22dc650dSSadaf Ebrahimiwhen PCRE2 is built; if not, the default is set to 250. An application can 63*22dc650dSSadaf Ebrahimichange this limit by calling pcre2_set_parens_nest_limit() to set the limit in 64*22dc650dSSadaf Ebrahimia compile context. 65*22dc650dSSadaf Ebrahimi</P> 66*22dc650dSSadaf Ebrahimi<P> 67*22dc650dSSadaf EbrahimiThe maximum length of name for a named capture group is 32 code units, and the 68*22dc650dSSadaf Ebrahimimaximum number of such groups is 10000. 69*22dc650dSSadaf Ebrahimi</P> 70*22dc650dSSadaf Ebrahimi<P> 71*22dc650dSSadaf EbrahimiThe maximum length of a name in a (*MARK), (*PRUNE), (*SKIP), or (*THEN) verb 72*22dc650dSSadaf Ebrahimiis 255 code units for the 8-bit library and 65535 code units for the 16-bit and 73*22dc650dSSadaf Ebrahimi32-bit libraries. 74*22dc650dSSadaf Ebrahimi</P> 75*22dc650dSSadaf Ebrahimi<P> 76*22dc650dSSadaf EbrahimiThe maximum length of a string argument to a callout is the largest number a 77*22dc650dSSadaf Ebrahimi32-bit unsigned integer can hold. 78*22dc650dSSadaf Ebrahimi</P> 79*22dc650dSSadaf Ebrahimi<P> 80*22dc650dSSadaf EbrahimiThe maximum amount of heap memory used for matching is controlled by the heap 81*22dc650dSSadaf Ebrahimilimit, which can be set in a pattern or in a match context. The default is a 82*22dc650dSSadaf Ebrahimivery large number, effectively unlimited. 83*22dc650dSSadaf Ebrahimi</P> 84*22dc650dSSadaf Ebrahimi<br><b> 85*22dc650dSSadaf EbrahimiAUTHOR 86*22dc650dSSadaf Ebrahimi</b><br> 87*22dc650dSSadaf Ebrahimi<P> 88*22dc650dSSadaf EbrahimiPhilip Hazel 89*22dc650dSSadaf Ebrahimi<br> 90*22dc650dSSadaf EbrahimiRetired from University Computing Service 91*22dc650dSSadaf Ebrahimi<br> 92*22dc650dSSadaf EbrahimiCambridge, England. 93*22dc650dSSadaf Ebrahimi<br> 94*22dc650dSSadaf Ebrahimi</P> 95*22dc650dSSadaf Ebrahimi<br><b> 96*22dc650dSSadaf EbrahimiREVISION 97*22dc650dSSadaf Ebrahimi</b><br> 98*22dc650dSSadaf Ebrahimi<P> 99*22dc650dSSadaf EbrahimiLast updated: August 2023 100*22dc650dSSadaf Ebrahimi<br> 101*22dc650dSSadaf EbrahimiCopyright © 1997-2023 University of Cambridge. 102*22dc650dSSadaf Ebrahimi<br> 103*22dc650dSSadaf Ebrahimi<p> 104*22dc650dSSadaf EbrahimiReturn to the <a href="index.html">PCRE2 index page</a>. 105*22dc650dSSadaf Ebrahimi</p> 106