PCRE2_SET_...ERN_LENGTH(3)

πŸŽ€ NAME πŸŽ€

PCRE2 - Perl-compatible regular expressions (revised API) πŸ’–

Okay bestie, this is the PCRE2_SET_...ERN_LENGTH(3) page from the PCRE2 Library Functions Manual β€” yes, the title has that whole ... situation going on, but that's literally the name, iykyk 🫢.


✨ SYNOPSIS ✨

#include <pcre2.h>

int pcre2_set_max_pattern_length(pcre2_compile_context *ccontext,
  PCRE2_SIZE value);

πŸ’… DESCRIPTION πŸ’…

So pcre2_set_max_pattern_length() sets, in a compile context, the maximum text length β€” measured in code units β€” of the pattern that can be compiled. The result is always zero. No cap, no drama, just 0 πŸ’….

If a longer pattern is passed to pcre2_compile(), boom: there is an immediate error return 😭. The default is effectively unlimited, being the largest value a PCRE2_SIZE variable can hold β€” so it's basically β€œgo off until the type itself runs out of room” ✨.

Not me setting a max pattern length and then immediately passing a longer one to pcre2_compile()... that's an immediate error return, bestie πŸ˜­πŸ’€.

For the full tea: there is a complete description of the PCRE2 native API in the pcre2api page, and a description of the POSIX API in the pcre2posix page πŸ§šπŸ’œ.


Cute little sign-off: this iconic page is from PCRE2 10.47, dated 05 October 2016, and its title is PCRE2_SET_...ERN_LENGTH(3) πŸŽ€πŸ’–. Periodt.

πŸ“¦ where this page comes from