PCRE_GET_SUBSTRING_LIST(3)
π NAME π
PCRE β literally just Perl-compatible regular expressions, bestie, that's the whole vibe π
β¨ SYNOPSIS β¨
#include <pcre.h>
int pcre_get_substring_list(const char *subject,
int *ovector, int stringcount, const char ***listptr);
int pcre16_get_substring_list(PCRE_SPTR16 subject,
int *ovector, int stringcount, PCRE_SPTR16 **listptr);
int pcre32_get_substring_list(PCRE_SPTR32 subject,
int *ovector, int stringcount, PCRE_SPTR32 **listptr);
Three flavours, one girlboss function: 8-bit, 16-bit, 32-bit. Pick your fighter. π¦
πΈ DESCRIPTION πΈ
Okay so this one is a convenience function β it's the chill bestie of the PCRE family whose entire job is extracting a whole list of all the captured substrings for you. No cap. π
The arguments are giving:
subjectβ the subject that has been successfully matched (yes, successfully, don't be out here passing your failed matches, that's not the move π)ovectorβ the offset vector thatpcre[16|32]_execusedstringcountβ the value returned bypcre[16|32]_execlistptrβ where to put a pointer to the list
Real talk: the memory where the substrings and the list live is obtained by calling pcre[16|32]_malloc(). And when you're done with it β because you will be done with it, you're not gonna hold onto that memory forever, right? right? β the convenience function pcre[16|32]_free_substring_list() is right there to free it for you. β¨
A pointer to a list of pointers gets put in the variable whose address lives in listptr. And the list is terminated by a NULL pointer, so when you're looping through it, that NULL is your lil' "ok we're done here" signal. π«Ά
The yield of the function is:
- zero on success β¨
PCRE_ERROR_NOMEMORYif sufficient memory could not be obtained π
No memory, no party. If you see PCRE_ERROR_NOMEMORY it's literally just telling you the allocation didn't work out β nothing more mysterious than that.
If you want the full tea: there's 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 too, they're iconic. π
okay that's the whole page, mwah π
This one's from PCRE 8.30, dated 24 June 2012 β yeah she's an elder but she still ate, fr fr. πβπ
π¦ where this page comes from
- alpine 3.22: pcre-doc 8.45-r4 Β· BSD-3-Clause
- alpine 3.23: pcre-doc 8.45-r4 Β· BSD-3-Clause
- alpine 3.24: pcre-doc 8.45-r4 Β· BSD-3-Clause
- arch rolling: pcre 8.45-5 Β· BSD
- centos-stream 9: pcre-devel 8.44-4.el9 Β· BSD
- centos-stream 9: pcre-devel 8.44-4.el9 Β· BSD
- debian bookworm: libpcre3-dev 2:8.39-15
- fedora 43: pcre-devel 8.45-1.fc43.9 Β· BSD-3-Clause
- fedora 43: pcre-devel 8.45-1.fc43.9 Β· BSD-3-Clause
- fedora 44: pcre-devel 8.45-1.fc43.9 Β· BSD-3-Clause
- fedora 44: pcre-devel 8.45-1.fc43.9 Β· BSD-3-Clause
- nixos 26.05: pcre 8.45
- nixos 26.05: pcre-cpp 8.45
- opensuse-leap 16.0: pcre-devel 8.45-160000.2.2 Β· BSD-3-Clause
- opensuse-leap 16.0: pcre-devel 8.45-160000.2.2 Β· BSD-3-Clause
- opensuse-leap 16.0: pcre-devel 8.45-160000.2.2 Β· BSD-3-Clause
- opensuse-leap 16.0: pcre-devel 8.45-160000.2.2 Β· BSD-3-Clause
- ubuntu jammy: libpcre3-dev 2:8.39-13build5
- ubuntu jammy: libpcre3-dev 2:8.39-13ubuntu0.22.04.1
- ubuntu noble: libpcre3-dev 2:8.39-15build1
- ubuntu questing: libpcre3-dev 2:8.39-15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms