PCRE2_SUBS...T_BYNUMBER(3)
π NAME π
PCRE2 β Perl-compatible regular expressions (revised API), bestie!! Fr fr, that's the whole vibe. β¨
π SYNOPSIS π
Like, here's the whole thing you gotta pull in first, no cap:
#include <pcre2.h>
int pcre2_substring_get_bynumber(pcre2_match_data *match_data,
uint32_t number, PCRE2_UCHAR **bufferptr, PCRE2_SIZE *bufflen);
Periodt. That's the function signature, character for character, don't @ me. π
πΈ DESCRIPTION πΈ
Okay so picture this: this is a convenience function for extracting a captured substring by number into newly acquired memory. It's giving "I got you, bestie" energy β it does the allocation dance so you don't have to. π«Ά
The arguments are, in order:
match_dataβ the match data for the match πnumberβ the number of the required substring (yes, by number, iykyk)bufferptrβ where to put the string pointerbufflenβ where to put the string length
The memory where the substring gets placed? It's obtained by calling the same memory allocation function that was used for the match data block. Consistency icon. β¨
π‘ When you're done with it, the convenience function pcre2_substring_free() can be used to free it β please actually free it, bestie, your process deserves better. π§
The yield of the function is zero for success, or one of these error numbers (write these down, they're on the exam):
PCRE2_ERROR_NOSUBSTRINGβ there are no groups of that number πPCRE2_ERROR_UNAVAILBLEβ the ovector was too small for that group π (that spelling is literally what the page says, copying it exactly, not my typo, I promise)PCRE2_ERROR_UNSETβ the group did not participate in the match πPCRE2_ERROR_NOMEMORYβ memory could not be obtained π
π¦ SEE ALSO (but make it cute) π¦
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, they ate. π₯
cute sign-off π β this little love letter comes from the PCRE2 10.47 manual, dated 13 December 2014. Slay, archive her, she's iconic. ππ
π¦ 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