PCRE_COPY_SUBSTRING(3)
π PCRE_COPY_SUBSTRING π
okay bestie, so this one lives in the Library Functions Manual, and it's page PCRE_COPY_SUBSTRING(3) β yes it's giving "library functions" energy, we love that for it. sit down, hydrate, we're doing substring extraction π
β¨ NAME β¨
PCRE β Perl-compatible regular expressions. that's the whole vibe. no cap. π
πΈ SYNOPSIS πΈ
like, here's the actual shape of it, don't @ me, this is verbatim:
#include <pcre.h>
int pcre_copy_substring(const char *subject, int *ovector,
int stringcount, int stringnumber, char *buffer,
int buffersize);
int pcre16_copy_substring(PCRE_SPTR16 subject, int *ovector,
int stringcount, int stringnumber, PCRE_UCHAR16 *buffer,
int buffersize);
int pcre32_copy_substring(PCRE_SPTR32 subject, int *ovector,
int stringcount, int stringnumber, PCRE_UCHAR32 *buffer,
int buffersize);
three versions, three widths, one iconique little function. 8-bit, 16-bit, 32-bit β pick your fighter π¦
π DESCRIPTION π
so basically, this is a convenience function for extracting a captured substring into a given buffer. it's the "just put the thing in the buffer already" function. the way it just does that? obsessed. β¨
the arguments are, and I'm gonna be so real with you:
subjectβ subject that has been successfully matched. like, the string you already ran through and it hit. π―ovectorβ the offset vector thatpcre[16|32]_exec()used. that's the receipts. π§Ύstringcountβ value returned bypcre[16|32]_exec(). yes, you gotta hand it back. it said what it said.stringnumberβ number of the required substring. which one you want, bestie. be specific.bufferβ buffer to receive the string. it's the lil container, the tote bag of it all πbuffersizeβ size ofbuffer. and you better get this right, I'm just saying π
β the yield, aka what you get back β
- the length of the string β slay, that's your win π
PCRE_ERROR_NOMEMORYβ if the buffer was too small. tragic. the buffer simply could not. πPCRE_ERROR_NOSUBSTRINGβ if the string number is invalid. you asked for a substring that does not exist, bestie. it's giving void. π
fr fr: if your buffer is too small you get PCRE_ERROR_NOMEMORY, not a truncated vibe. size it correctly or perish (gently). π«Ά
π where to go next π
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, iykyk πβ¨
and that's the whole page, bestie. this was PCRE 8.30, dated 24 June 2012 β yeah she's an elder but she still ate. mwah π π
π¦ 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