PCRE_COMPILE2(3)
π PCRE_COMPILE2 π
okay bestie, welcome to the PCRE_COMPILE2(3) page, straight out of the Library Functions Manual β¨ this is the one where we compile regexes and also get told exactly what went wrong, so pull up a chair π«Ά
πΈ NAME πΈ
PCRE β Perl-compatible regular expressions π
β¨ SYNOPSIS β¨
no cap, this is literally the whole vibe:
#include <pcre.h>
pcre *pcre_compile2(const char *pattern, int options,
int *errorcodeptr,
const char **errptr, int *erroffset,
const unsigned char *tableptr);
pcre16 *pcre16_compile2(PCRE_SPTR16 pattern, int options,
int *errorcodeptr,
const char **errptr, int *erroffset,
const unsigned char *tableptr);
pcre32 *pcre32_compile2(PCRE_SPTR32 pattern, int options,
int *errorcodeptr,Β£
const char **errptr, int *erroffset,
const unsigned char *tableptr);
π¦ DESCRIPTION π¦
so this function compiles a regular expression into an internal form π it's the same as pcre[16|32]_compile(), except it's got one extra little bestie along for the ride: the errorcodeptr argument π«Ά
the arguments, let's go:
patternβ A zero-terminated string containing the regular expression to be compiled β¨optionsβ Zero or more option bits πerrorcodeptrβ Where to put an error code π¨errptrβ Where to put an error message πerroffsetβ Offset inpatternwhere error was found πtableptrβ Pointer to character tables, orNULLto use the built-in default π
π The Option Bits π
one bullet per bit, no skipping, we don't do that here:
PCRE_ANCHOREDβ Force pattern anchoring βPCRE_AUTO_CALLOUTβ Compile automatic callouts π£PCRE_BSR_ANYCRLFβ\Rmatches only CR, LF, or CRLFPCRE_BSR_UNICODEβ\Rmatches all Unicode line endings πPCRE_CASELESSβ Do caseless matching πPCRE_DOLLAR_ENDONLYβ$not to match newline at end πΈPCRE_DOTALLβ.matches anything including NL π«§PCRE_DUPNAMESβ Allow duplicate names for subpatterns π―PCRE_EXTENDEDβ Ignore white space and#comments π§ΌPCRE_EXTRAβ PCRE extra features (not much use currently) πPCRE_FIRSTLINEβ Force matching to be before newline π₯PCRE_JAVASCRIPT_COMPATβ JavaScript compatibility π¨PCRE_MULTILINEβ^and$match newlines within data πPCRE_NEVER_UTFβ Lock out UTF, e.g. via(*UTF)πPCRE_NEWLINE_ANYβ Recognize any Unicode newline sequence πPCRE_NEWLINE_ANYCRLFβ Recognize CR, LF, and CRLF as newline sequences πPCRE_NEWLINE_CRβ Set CR as the newline sequencePCRE_NEWLINE_CRLFβ Set CRLF as the newline sequencePCRE_NEWLINE_LFβ Set LF as the newline sequencePCRE_NO_AUTO_CAPTUREβ Disable numbered capturing parentheses (named ones available) πPCRE_NO_AUTO_POSSESSβ Disable auto-possessification πPCRE_NO_START_OPTIMIZEβ Disable match-time start optimizations πPCRE_NO_UTF16_CHECKβ Do not check the pattern for UTF-16 validity (only relevant ifPCRE_UTF16is set) π§PCRE_NO_UTF32_CHECKβ Do not check the pattern for UTF-32 validity (only relevant ifPCRE_UTF32is set) π§PCRE_NO_UTF8_CHECKβ Do not check the pattern for UTF-8 validity (only relevant ifPCRE_UTF8is set) π§PCRE_UCPβ Use Unicode properties for\d,\w, etc. π¦PCRE_UNGREEDYβ Invert greediness of quantifiers π€PCRE_UTF16β Runpcre16_compile()in UTF-16 modePCRE_UTF32β Runpcre32_compile()in UTF-32 modePCRE_UTF8β Runpcre_compile()in UTF-8 mode
π¨ bestie, real talk: PCRE must be built with UTF support in order to usePCRE_UTF8/16/32andPCRE_NO_UTF8/16/32_CHECK, and with UCP support ifPCRE_UCPis used. no build flags, no vibes. π
π What You Get Back π
the yield of the function is a pointer to a private data structure that contains the compiled pattern π or NULL if an error was detected π
β οΈ and listen: compiling regular expressions with one version of PCRE for use with a different version is not guaranteed to work and may cause crashes π₯ fr fr, don't do it.
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 πΈ
π SEE ALSO π
pcreapiβ the full native API tea βpcreposixβ the POSIX API tea β
and that's the whole page, bestie!! compiled with love by PCRE 8.34, dated 01 October 2013 π mwah, go forth and match some patterns π β¨π¦
π¦ 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