PCRE16_COPY_NAMED_SUBSTRING(3)

okay so bestie, this page comes from the Library Functions Manual and it's all about PCRE_COPY_...D_SUBSTRING(3) πŸ’…βœ¨

✨ NAME ✨

PCRE β€” Perl-compatible regular expressions πŸ¦‹


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <pcre.h>

int pcre_copy_named_substring(const pcre *code,
     const char *subject, int *ovector,
     int stringcount, const char *stringname,
     char *buffer, int buffersize);

int pcre16_copy_named_substring(const pcre16 *code,
     PCRE_SPTR16 subject, int *ovector,
     int stringcount, PCRE_SPTR16 stringname,
     PCRE_UCHAR16 *buffer, int buffersize);

int pcre32_copy_named_substring(const pcre32 *code,
     PCRE_SPTR32 subject, int *ovector,
     int stringcount, PCRE_SPTR32 stringname,
     PCRE_UCHAR32 *buffer, int buffersize);

πŸ’– DESCRIPTION πŸ’–

okay so this is literally a convenience function for extracting a captured substring, identified by name, into a given buffer. it's giving "i got you, bestie" energy 🫢

the arguments are:

  • code β€” the pattern that was successfully matched πŸ‘‘
  • subject β€” the subject that has been successfully matched 🌸
  • ovector β€” the offset vector that pcre[16|32]_exec() used πŸŽ€
  • stringcount β€” the value returned by pcre[16|32]_exec() ✨
  • stringname β€” the name of the required substring πŸ¦‹
  • buffer β€” the buffer to receive the string πŸ’–
  • buffersize β€” the size of buffer πŸ’…

the yield is the length of the substring, PCRE_ERROR_NOMEMORY if the buffer was too small, or PCRE_ERROR_NOSUBSTRING if the string name is invalid. no cap. 😭

there is a complete description of the PCRE native API in the pcreapi page and a description of the POSIX API in the pcreposix page. go read those if you want the full lore πŸ“š


and that's the tea β˜• this page is from PCRE 8.30, dated 24 June 2012. periodt πŸ’…βœ¨