PCRE2_SET_COMPILE_EXTRA_OPTIONS(3)

πŸ’… PCRE2_SET_COMPILE_EXTRA_OPTIONS πŸ’…

okay bestie, so this is a page from the Library Functions Manual β€” yes, the Library Functions Manual, we're in the big leagues now β€” and it's all about PCRE2, aka Perl-compatible regular expressions (revised API). Regex girlies rise up πŸ¦‹


✨ NAME ✨

PCRE2 β€” Perl-compatible regular expressions (revised API). that's it, that's the name, no cap πŸŽ€


🌸 SYNOPSIS 🌸

#include <pcre2.h>

int pcre2_set_compile_extra_options(pcre2_compile_context *ccontext,
  uint32_t extra_options);

πŸ’– DESCRIPTION πŸ’–

so what does this function actually do? it sets additional option bits for pcre2_compile() β€” the bits live in a compile context β€” and here's the thing that matters, the main-character detail: it completely replaces all the bits. not merges, not nudges, not "adds a lil something". replaces. all of them. so if you were expecting your old flags to survive, nope, they are gone πŸ™ˆ

now the extra options themselves, and there are a lot of them β€” slay πŸ”₯

  • PCRE2_EXTRA_ALLOW_LOOKAROUND_BSK β€” Allow \K in lookarounds
  • PCRE2_EXTRA_ALLOW_SURROGATE_ESCAPES β€” Allow \x{d800} to \x{dfff} in UTF-8 and UTF-32 modes
  • PCRE2_EXTRA_ALT_BSUX β€” Extended alternate \u, \U, and \x handling
  • PCRE2_EXTRA_ASCII_BSD β€” \d remains ASCII in UCP mode
  • PCRE2_EXTRA_ASCII_BSS β€” \s remains ASCII in UCP mode
  • PCRE2_EXTRA_ASCII_BSW β€” \w remains ASCII in UCP mode
  • PCRE2_EXTRA_ASCII_DIGIT β€” [:digit:] and [:xdigit:] POSIX classes remain ASCII in UCP mode
  • PCRE2_EXTRA_ASCII_POSIX β€” POSIX classes remain ASCII in UCP mode
  • PCRE2_EXTRA_BAD_ESCAPE_IS_LITERAL β€” Treat all invalid escapes as a literal following character
  • PCRE2_EXTRA_CASELESS_RESTRICT β€” Disable mixed ASCII/non-ASCII case folding
  • PCRE2_EXTRA_ESCAPED_CR_IS_LF β€” Interpret \r as \n
  • PCRE2_EXTRA_MATCH_LINE β€” Pattern matches whole lines
  • PCRE2_EXTRA_MATCH_WORD β€” Pattern matches "words"
  • PCRE2_EXTRA_NEVER_CALLOUT β€” Disallow callouts in pattern
  • PCRE2_EXTRA_NO_BS0 β€” Disallow \0 (but not \00 or \000)
  • PCRE2_EXTRA_PYTHON_OCTAL β€” Use Python rules for octal
  • PCRE2_EXTRA_TURKISH_CASING β€” Use Turkish I case folding

like, seventeen of them. seventeen! we ate πŸ’…βœ¨


and if you want the full lore, there's a complete description of the PCRE2 native API in the pcre2api page, and a description of the POSIX API in the pcre2posix page. go read them, iykyk 🫢


mwah, that's the whole page β€” this one's from PCRE2 10.47, dated 14 October 2024, and it's the PCRE2_SET_...TRA_OPTIONS(3) page, so like... go forth and set your compile extra options, bestie πŸ’œ

πŸ“¦ where this page comes from