PCRE2_MATC...OM_PATTERN(3)
β¨ NAME β¨
okay so this is the manual page for pcre2_match_data_create_from_pattern β it's from the Library Functions Manual, section 3 of the PCRE2 docs, and it's literally all about Perl-compatible regular expressions (revised API). bestie, PCRE2 is the whole vibe here π
π SYNOPSIS π
like, here's the exact shape of it, no cap:
#include <pcre2.h>
pcre2_match_data *pcre2_match_data_create_from_pattern(
const pcre2_code *code, pcre2_general_context *gcontext);
she takes a const pcre2_code * called code and a pcre2_general_context * called gcontext, and she hands you back a pcre2_match_data *. iconique β¨
πΈ DESCRIPTION πΈ
okay so bestie, what this function does is: it creates a brand-new match data block π β like, a little container that's gonna hold the result of a match. that's her whole job.
now the important part, don't skip this π β if the first argument is NULL, this function returns NULL. periodt, no match data for you. otherwise, that first argument points to a compiled pattern.
so then: the number of capturing parentheses inside the pattern is what gets used to work out how many pairs of offsets are needed in the match data block. those pairs form the "output vector" (aka the ovector) inside the match data block, and they're what identifies the matched string and any captured substrings when you're matching with pcre2_match(). iykyk π§
π¨ quick vibe check / lowkey important warning: if you're usingpcre2_dfa_match(), which uses the output vector in a different way, you should usepcre2_match_data_create()instead of this function. like, don't be cute and use this one there. π
now the second argument β gcontext β points to a general context, which is for custom memory management. or you can pass NULL and it'll use the same memory allocator that was used for the compiled pattern. either way, bestie π
and the result of the function is NULL if the memory for the block could not be obtained, or if NULL was provided as the first argument. two totally normal reasons to get NULL back. no drama. π
also! 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 those if you want the full lore π¦
π SEE ALSO π
pcre2apiβ the full, complete description of the PCRE2 native API πpcre2posixβ the description of the POSIX API β
π«Ά and that's the whole thing, bestie! sending you off with the deets: this is PCRE2 10.47, dated 11 August 2025, and it lives at PCRE2_MATC...OM_PATTERN(3) in the manual. slay, go write some regexes π
π₯
π¦ where this page comes from
- fedora 43: pcre2-devel 10.47-1.fc43 Β· BSD-3-Clause AND FSFULLR AND X11 AND GPL-2.0-or-later AND FSFAP AND FSFUL AND GPL-3.0-or-later
- fedora 43: pcre2-devel 10.47-1.fc43 Β· BSD-3-Clause AND FSFULLR AND X11 AND GPL-2.0-or-later AND FSFAP AND FSFUL AND GPL-3.0-or-later
- fedora 44: pcre2-devel 10.47-1.fc44.1 Β· BSD-3-Clause AND FSFULLR AND X11 AND GPL-2.0-or-later AND FSFAP AND FSFUL AND GPL-3.0-or-later
- fedora 44: pcre2-devel 10.47-1.fc44.1 Β· BSD-3-Clause AND FSFULLR AND X11 AND GPL-2.0-or-later AND FSFAP AND FSFUL AND GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms