PCRE2_NEXT_MATCH(3)
π PCRE2_NEXT_MATCH π
okay so bestie, welcome to the Library Functions Manual entry for PCRE2_NEXT_MATCH (3) β yes that's the section number, it's giving very reference section of you to notice π
β¨ NAME β¨
PCRE2 β Perl-compatible regular expressions (revised API) π¦
πΈ SYNOPSIS πΈ
#include <pcre2.h>
int pcre2_next_match(pcre2_match_data *match_data,
PCRE2_SIZE *pstart_offset, uint32_t *poptions);
π DESCRIPTION π
so this function? it's the after-party function. like, you call it after one of the match functions β that's pcre2_match(), pcre2_dfa_match(), or pcre2_jit_match() β and you must hand it the same match_data parameter. same one. no substitutions, iykyk π
what it does: it outputs the appropriate parameters for searching for the next match in the same subject string. and honestly? it's built for the "global matching" girlies β applications that want "global" matching behaviour, like:
- replacing all matches in the subject π
- splitting the subject on all matches β¨
- or simply counting the number of matches π
it returns 0 ("false") if there's no need to make any further match attempts, or 1 ("true") if another match should be attempted. that's the whole vibe check, fr fr.
the *pstart_offset and *poptions get set if the function returns 1. so:
*pstart_offsetβ pass this to the next match attempt directly. no thoughts, just pass it π«Ά*poptionsβ pass this to the next match attempt by combining it with the application's match options using OR. that's the glue that holds the whole thing together bestie, don't skip the OR π
lowkey important:*pstart_offsetand*poptionsare only set when the return value is1. if you got a0, there's nothing to pass along, periodt.
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 too, they're iconic π
and that's the whole page, no notes π this was PCRE2 10.49, dated 24 March 2025, straight from the PCRE2_NEXT_MATCH (3) girlies β stay matching, bestie, and may all your offsets be valid πβ¨
π¦ where this page comes from
- alpine 3.23: pcre2-doc 10.49-r0 Β· BSD-3-Clause
- alpine 3.24: pcre2-doc 10.49-r0 Β· BSD-3-Clause
- arch rolling: pcre2 10.49-1 Β· BSD-2-Clause AND BSD-3-Clause WITH PCRE2-exception
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms