PCRE_FULLINFO(3)

πŸ’– PCRE_FULLINFO β€” bestie, come get the tea on your compiled pattern πŸ’–

okay so this is the pcre_fullinfo page from the PCRE manual (that's Perl-compatible regular expressions, and yes she ate). grab a snack, we're getting all the lore about a pattern you already compiled.


✨ SYNOPSIS ✨

first things first, pull in the header:

#include <pcre.h>

then here's the whole girlboss lineup β€” three of them, one for each library width, all identical in shape:

int pcre_fullinfo(const pcre *code, const pcre_extra *extra,
     int what, void *where);

int pcre16_fullinfo(const pcre16 *code, const pcre16_extra *extra,
     int what, void *where);

int pcre32_fullinfo(const pcre32 *code, const pcre32_extra *extra,
     int what, void *where);

🌸 DESCRIPTION 🌸

so this function is literally just gossip about a compiled pattern. it tells you stuff. that's the whole job. here's who's in the group chat:

  • code β€” the compiled regular expression 🫢
  • extra β€” whatever pcre[16|32]_study() handed back, or NULL
  • what β€” which piece of info you're asking for
  • where β€” where the info should go

πŸŽ€ the info menu (a.k.a. what you can ask for) πŸŽ€

  • PCRE_INFO_BACKREFMAX β€” number of the highest back reference
  • PCRE_INFO_CAPTURECOUNT β€” number of capturing subpatterns
  • PCRE_INFO_DEFAULT_TABLES β€” pointer to default tables
  • PCRE_INFO_FIRSTBYTE β€” fixed first data unit for a match, or -1 for start of string or after newline, or -2 otherwise
  • PCRE_INFO_FIRSTTABLE β€” table of first data units (after studying)
  • PCRE_INFO_HASCRORLF β€” returns 1 if explicit CR or LF matches exist
  • PCRE_INFO_JCHANGED β€” returns 1 if (?J) or (?-J) was used
  • PCRE_INFO_JIT β€” returns 1 after successful JIT compilation
  • PCRE_INFO_JITSIZE β€” size of JIT compiled code
  • PCRE_INFO_LASTLITERAL β€” literal last data unit required
  • PCRE_INFO_MINLENGTH β€” lower bound length of matching strings
  • PCRE_INFO_MATCHEMPTY β€” returns 1 if the pattern can match an empty string, 0 otherwise
  • PCRE_INFO_MATCHLIMIT β€” match limit if set, otherwise PCRE_RROR_UNSET
  • PCRE_INFO_MAXLOOKBEHIND β€” length (in characters) of the longest lookbehind assertion
  • PCRE_INFO_NAMECOUNT β€” number of named subpatterns
  • PCRE_INFO_NAMEENTRYSIZE β€” size of name table entry
  • PCRE_INFO_NAMETABLE β€” pointer to name table
  • PCRE_INFO_OKPARTIAL β€” returns 1 if partial matching can be tried (always returns 1 after release 8.00)
  • PCRE_INFO_OPTIONS β€” option bits used for compilation
  • PCRE_INFO_SIZE β€” size of compiled pattern
  • PCRE_INFO_STUDYSIZE β€” size of study data
  • PCRE_INFO_FIRSTCHARACTER β€” fixed first data unit for a match
  • PCRE_INFO_FIRSTCHARACTERFLAGS β€” returns 1 if there is a first data character set, which can then be retrieved using PCRE_INFO_FIRSTCHARACTER; 2 if the first character is at the start of the data string or after a newline; and 0 otherwise
  • PCRE_INFO_RECURSIONLIMIT β€” recursion limit if set, otherwise PCRE_ERROR_UNSET
  • PCRE_INFO_REQUIREDCHAR β€” literal last data unit required
  • PCRE_INFO_REQUIREDCHARFLAGS β€” returns 1 if the last data character is set (which can then be retrieved using PCRE_INFO_REQUIREDCHAR); 0 otherwise

πŸ¦‹ what where has to point at πŸ¦‹

bestie listen. normally your where argument has to point at an integer variable. except for these what values, which need their own special lil types:

  • PCRE_INFO_DEFAULT_TABLES β€” const uint8_t *
  • PCRE_INFO_FIRSTCHARACTER β€” uint32_t
  • PCRE_INFO_FIRSTTABLE β€” const uint8_t *
  • PCRE_INFO_JITSIZE β€” size_t
  • PCRE_INFO_MATCHLIMIT β€” uint32_t
  • PCRE_INFO_NAMETABLE β€” PCRE_SPTR16 (16-bit library)
  • PCRE_INFO_NAMETABLE β€” PCRE_SPTR32 (32-bit library)
  • PCRE_INFO_NAMETABLE β€” const unsigned char * (8-bit library)
  • PCRE_INFO_OPTIONS β€” unsigned long int
  • PCRE_INFO_SIZE β€” size_t
  • PCRE_INFO_STUDYSIZE β€” size_t
  • PCRE_INFO_RECURSIONLIMIT β€” uint32_t
  • PCRE_INFO_REQUIREDCHAR β€” uint32_t

πŸ’… the return value πŸ’…

the function yields zero on success. and when it doesn't? she gives you one of these instead:

  • PCRE_ERROR_NULL β€” the argument code was NULL
    • or the argument where was NULL
  • PCRE_ERROR_BADMAGIC β€” the "magic number" was not found πŸͺ„
  • PCRE_ERROR_BADOPTION β€” the value of what was invalid
  • PCRE_ERROR_UNSET β€” the option was not set

πŸ’€ heads up: there's a whole complete description of the PCRE native API chilling in the pcreapi page, and a description of the POSIX API in the pcreposix page. go read those too, no cap.

and that's the whole page, bestie, you're officially informed ✨ this was PCRE 8.36, dated 21 April 2014, and it lives under PCRE_FULLINFO(3). mwah, go slay those regexes πŸ’–πŸŽ€πŸ¦‹