PCRE2_NEXT_MATCH(3)

πŸ“¦
version 10.49 Β· 2 versions
, in alpine 3.23, alpine 3.24, arch rolling

πŸ’– 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_offset and *poptions are only set when the return value is 1. if you got a 0, 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