PCRE_EXEC(3)
π NAME π
PCRE β Perl-compatible regular expressions β¨ (and bestie, that's the whole vibe of the pcre_exec family of functions, iykyk)
β¨ SYNOPSIS β¨
okay so first you gotta pull in the header, like always:
#include <pcre.h>
and then the three icons themselves π :
int pcre_jit_exec(const pcre *code, const pcre_extra *extra,
const char *subject, int length, int startoffset,
int options, int *ovector, int ovecsize,
pcre_jit_stack *jstack);
int pcre16_jit_exec(const pcre16 *code, const pcre16_extra *extra,
PCRE_SPTR16 subject, int length, int startoffset,
int options, int *ovector, int ovecsize,
pcre_jit_stack *jstack);
int pcre32_jit_exec(const pcre32 *code, const pcre32_extra *extra,
PCRE_SPTR32 subject, int length, int startoffset,
int options, int *ovector, int ovecsize,
pcre_jit_stack *jstack);
three bit-widths, one queen energy π
π¦ DESCRIPTION π¦
okay so picture this: you've got a compiled regular expression that's already been successfully studied with one of the JIT options, and now you wanna match it against a subject string. That's literally what this does. It uses a matching algorithm that's similar to Perl's, and it's the "fast path" interface to JIT β which lowkey means it bypasses some of the sanity checks that pcre_exec() applies. π«£ (fr fr, the checks are just not there, bestie.)
It returns offsets to captured substrings. Its arguments are:
codeβ Points to the compiled patternextraβ Points to an associatedpcre[16|32]_extrastructure, or isNULLsubjectβ Points to the subject stringlengthβ Length of the subject string, in bytesstartoffsetβ Offset in bytes in the subject at which to start matchingoptionsβ Option bitsovectorβ Points to a vector of ints for result offsetsovecsizeβ Number of elements in the vector (a multiple of 3)jstackβ Pointer to a JIT stack
πΈ the allowed options πΈ
PCRE_NOTBOLβ Subject string is not the beginning of a linePCRE_NOTEOLβ Subject string is not the end of a linePCRE_NOTEMPTYβ An empty string is not a valid matchPCRE_NOTEMPTY_ATSTARTβ An empty string at the start of the subject is not a valid matchPCRE_NO_UTF16_CHECKβ Do not check the subject for UTF-16 validity (only relevant ifPCRE_UTF16was set at compile time)PCRE_NO_UTF32_CHECKβ Do not check the subject for UTF-32 validity (only relevant ifPCRE_UTF32was set at compile time)PCRE_NO_UTF8_CHECKβ Do not check the subject for UTF-8 validity (only relevant ifPCRE_UTF8was set at compile time)PCRE_PARTIALβ ) ReturnPCRE_ERROR_PARTIALfor a partial match if no full matches are foundPCRE_PARTIAL_SOFTβ ) ReturnPCRE_ERROR_PARTIALfor a partial match if no full matches are foundPCRE_PARTIAL_HARDβ ReturnPCRE_ERROR_PARTIALfor a partial match if that is found before a full match
π note thatPCRE_PARTIALandPCRE_PARTIAL_SOFTare grouped together in the original with those little)markers, andPCRE_PARTIAL_HARDis the one doing its own thing.
However β and this is the plot twist π β the PCRE_NO_UTF[8|16|32]_CHECK options have no effect, because this check is never applied. So don't be out here thinking they're gonna do something, bestie, they're just chilling there. For details of partial matching, see the pcrepartial page.
π the pcre_extra structure π
A pcre_extra structure contains the following fields:
flagsβ Bits indicating which fields are setstudy_dataβ Opaque data frompcre[16|32]_study()match_limitβ Limit on internal resource usematch_limit_recursionβ Limit on internal recursion depthcallout_dataβ Opaque data passed back to calloutstablesβ Points to character tables or isNULLmarkβ For passing back a*MARKpointerexecutable_jitβ Opaque data from JIT compilation
π the flag bits π
The flag bits are PCRE_EXTRA_STUDY_DATA, PCRE_EXTRA_MATCH_LIMIT, PCRE_EXTRA_MATCH_LIMIT_RECURSION, PCRE_EXTRA_CALLOUT_DATA, PCRE_EXTRA_TABLES, PCRE_EXTRA_MARK and PCRE_EXTRA_EXECUTABLE_JIT. β¨
There is a complete description of the PCRE native API in the pcreapi page and a description of the JIT API in the pcrejit page. Go read those, they ate. π₯
and that's the whole page, bestie!! π«Ά this was PCRE 8.30, dated 31 October 2012, from the Library Functions Manual β slay, no cap, periodt π β¨
π¦ 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