PCRE_GET_STRINGNUMBER(3)
β¨ PCRE_GET_STRINGNUMBER β¨
okay so bestie, welcome to the PCRE manual β that's Perl-compatible regular expressions, and this page right here is about one lil function that does one lil job. it's giving "small but mighty" energy. π
πΈ NAME πΈ
PCRE β Perl-compatible regular expressions. that's it, that's the name, no notes. π
π SYNOPSIS π
so here's how you call it. first you gotta include the header:
#include <pcre.h>
and then there's not one, not two, but three versions of this function β one for each width, because PCRE said "why pick a character size when you can have all of them" β¨
int pcre_get_stringnumber(const pcre *code,
const char *name);
int pcre16_get_stringnumber(const pcre16 *code,
PCRE_SPTR16 name);
int pcre32_get_stringnumber(const pcre32 *code,
PCRE_SPTR32 name);
π¦ DESCRIPTION π¦
okay so the tea β: this is a convenience function, which is just fancy speak for "we made this easy for you, you're welcome." what it does is it finds the number of a named substring capturing parenthesis inside a compiled pattern. basically: you gave a capture group a cute lil name, and now you wanna know what index it's sitting at. and this function tells you. π«Ά
here's the two arguments it takes, laid out all pretty:
codeβ the compiled regular expression. yes, the whole thing, already compiled. πnameβ the name whose number is required. like, you hand over the name, it hands back the digits. iconic behavior fr fr.
π what you get back π
the yield of the function is the number of the parenthesis if the name is found. and if it's not found? you get PCRE_ERROR_NOSUBSTRING instead. so like, bestie, check your return value, don't just assume. π
β οΈ important caveat alert, no cap: when duplicate names are allowed (PCRE_DUPNAMESis set), it is not defined which of the numbers is returned bypcre[16|32]_get_stringnumber(). that's right β undefined. it's a vibe, not a promise. π
and if you do need the whole squad, you can obtain the complete list by calling pcre[16|32]_get_stringtable_entries(). that one's your group-chat roster. π
π where to go next π
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, they ate. π₯
that's the whole page bestie, you're officially un-stuck π
sign-off: this was PCRE 8.30, dated 24 June 2012 β and it lives in the Library Functions Manual. 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