PCRE2_MATCH_DATA_CREATE(3)

πŸ’… PCRE2_MATCH_DATA_CREATE πŸ’…

okay so bestie, welcome to the PCRE2 glow-up β€” this is the revised API page for pcre2_match_data_create and it's literally the moment your regex results get a place to live 🏠✨ (the manual's full name is PCRE2 β€” Perl-compatible regular expressions, iykyk).


✨ SYNOPSIS ✨

like, here's the vibe:

#include <pcre2.h>

pcre2_match_data *pcre2_match_data_create(uint32_t ovecsize,
  pcre2_general_context *gcontext);

πŸŽ€ DESCRIPTION πŸŽ€

okay so this function creates a brand new match data block πŸ¦‹ β€” and that's the little home where the result of a match gets held. main character energy, honestly.

The first argument (ovecsize) tells it how many pairs of offsets you need. Those pairs form the "output vector" (aka the ovector) inside the match data block, and they're what identify the matched string plus any captured substrings when you match with pcre2_match(), or a number of different matches at the same point when you use it with pcre2_dfa_match(). 🫢

heads up bestie: there is always one pair of offsets β€” so if ovecsize is zero, it's treated as one. no zero-pair situations here, periodt πŸ’…

The second argument points to a general context (that's your custom memory management hookup), or it's NULL for system memory management. And if the memory for the block couldn't be obtained? The function's result is NULL 😭 β€” plan accordingly.

There's a complete description of the PCRE2 native API over in the pcre2api page, and a description of the POSIX API in the pcre2posix page β€” go read those if you want the full lore πŸ“šβœ¨


πŸ’€ reminder that this whole page is the revised API, so don't go mixing it up with the old one, ngl.

and that's the tea, bestie πŸ“ this page is from PCRE2 10.47, dated 28 August 2021 β€” slay, iconic, ate, no cap πŸ’–πŸ§šβ€β™€οΈ

πŸ“¦ where this page comes from