std/pcre2

Search:
Source   Edit  

The following option bits can be passed only to pcre2_compile(). However, they may affect compilation, JIT compilation, and/or interpretive execution. The following tags indicate which:

C alters what is compiled by pcre2_compile() J alters what is compiled by pcre2_jit_compile() M is inspected during pcre2_match() execution D is inspected during pcre2_dfa_match() execution

An additional compile options word is available in the compile context.These are for pcre2_jit_compile().These are for pcre2_match(), pcre2_dfa_match(), pcre2_jit_match(), and pcre2_substitute(). Some are allowed only for one of the functions, and in these cases it is noted below. Note that ANCHORED, ENDANCHORED and NO_UTF_CHECK can also be passed to these functions (though pcre2_jit_match() ignores the latter since it bypasses all sanity checks).Options for pcre2_pattern_convert().Newline and R settings, for use in compile contexts. The newline values must be kept in step with values set in config.h and both sets must all be greater than zero.Error codes for pcre2_compile(). Some of these are also used by pcre2_pattern_convert().Error 159 is obsolete and should now never occur"Expected" matching error codes: no match and partial match.Error codes for UTF-8 validity checksError codes for UTF-16 validity checksError codes for UTF-32 validity checksMiscellaneous error codes for pcre2_dfa_match(), substring extraction functions, context functions, and serializing functions. They are in numerical order. Originally they were in alphabetical order too, but now that PCRE2 is released, the numbers must not be changed.Request types for pcre2_pattern_info()Request types for pcre2_config().Optimization directives for pcre2_set_optimize(). For binary compatibility, only add to this list; do not renumber.Types used in pcre2_set_substitute_case_callout().

Types

CalloutBlock = object
  version*: cint             ## Identifies version of block
  callout_number*: cint      ## Number compiled into pattern
  offset_vector*: ptr cint   ## The offset vector
  subject*: cstring          ## The subject being matched
  subject_length*: cint      ## The length of the subject
  start_match*: cint         ## Offset to start of this match attempt
  current_position*: cint    ## Where we currently are in the subject
  capture_top*: cint         ## Max current capture
  capture_last*: cint        ## Most recently closed capture
  callout_data*: pointer     ## Data passed in with the call
  pattern_position*: cint    ## Offset to next item in the pattern
  next_item_length*: cint    ## Length of next item in the pattern
  mark*: pointer             ## Pointer to current mark or NULL
Source   Edit  
GeneralContext = object
Source   Edit  
JitCallback = proc (a: pointer): ptr JitStack {.cdecl.}
Source   Edit  
JitStack = object
Source   Edit  
JitStack16 = object
Source   Edit  
JitStack32 = object
Source   Edit  
MatchData = object
Source   Edit  
Pcre = object
Source   Edit  
Pcre16 = object
Source   Edit  
Pcre32 = object
Source   Edit  

Consts

ALLOW_EMPTY_CLASS = 0x00000001'u32
Source   Edit  
ALT_BSUX = 0x00000002'u32
Source   Edit  
ALT_CIRCUMFLEX = 0x00200000'u32
Source   Edit  
ALT_EXTENDED_CLASS = 0x00080000'u32
Source   Edit  
ALT_VERBNAMES = 0x00400000'u32
Source   Edit  
ANCHORED = 0x80000000'u32
Source   Edit  
AUTO_CALLOUT = 0x00000004'u32
Source   Edit  
AUTO_POSSESS = 64
Source   Edit  
BSR_ANYCRLF = 2
Source   Edit  
BSR_UNICODE = 1
Source   Edit  
CASELESS = 0x00000008'u32
Source   Edit  
CONFIG_BSR = 0
Source   Edit  
CONFIG_JIT = 1
Source   Edit  
CONFIG_NEWLINE = 5
Source   Edit  
CONFIG_UNICODE = 9
Source   Edit  
CONFIG_VERSION = 11
Source   Edit  
CONVERT_GLOB = 0x00000010'u32
Source   Edit  
CONVERT_GLOB_NO_STARSTAR = 0x00000050'u32
Source   Edit  
CONVERT_GLOB_NO_WILD_SEPARATOR = 0x00000030'u32
Source   Edit  
CONVERT_NO_UTF_CHECK = 0x00000002'u32
Source   Edit  
CONVERT_POSIX_BASIC = 0x00000004'u32
Source   Edit  
CONVERT_POSIX_EXTENDED = 0x00000008'u32
Source   Edit  
CONVERT_UTF = 0x00000001'u32
Source   Edit  
COPY_MATCHED_SUBJECT = 0x00004000'u32
Source   Edit  
DFA_RESTART = 0x00000040'u32
Source   Edit  
DFA_SHORTEST = 0x00000080'u32
Source   Edit  
DISABLE_RECURSELOOP_CHECK = 0x00040000'u32
Source   Edit  
DOLLAR_ENDONLY = 0x00000010'u32
Source   Edit  
DOTALL = 0x00000020'u32
Source   Edit  
DOTSTAR_ANCHOR = 66
Source   Edit  
DUPNAMES = 0x00000040'u32
Source   Edit  
ENDANCHORED = 0x20000000'u32
Source   Edit  
ERROR_BAD_OPTIONS = 117
Source   Edit  
ERROR_BADDATA = -29
Source   Edit  
ERROR_BADMAGIC = -31
Source   Edit  
ERROR_BADMODE = -32
Source   Edit  
ERROR_BADOFFSET = -33
Source   Edit  
ERROR_BADOPTION = -34
Source   Edit  
ERROR_CALLOUT = -37
Never used by PCRE2 itself Source   Edit  
ERROR_DEPTHLIMIT = -53
Source   Edit  
ERROR_DFA_RECURSE = -39
Source   Edit  
ERROR_DFA_UCOND = -40
Source   Edit  
ERROR_DFA_UFUNC = -41
Source   Edit  
ERROR_DFA_UITEM = -42
Source   Edit  
ERROR_DFA_WSSIZE = -43
Source   Edit  
ERROR_HEAP_FAILED = 121
Source   Edit  
ERROR_HEAPLIMIT = -63
Source   Edit  
ERROR_INTERNAL = -44
Source   Edit  
ERROR_MATCHLIMIT = -47
Source   Edit  
ERROR_MIXEDTABLES = -30
Name was changed Source   Edit  
ERROR_NOMATCH = -1
Source   Edit  
ERROR_NOMEMORY = -48
Source   Edit  
ERROR_NOSUBSTRING = -49
Source   Edit  
ERROR_NULL = -51
Source   Edit  
ERROR_PARTIAL = -2
Source   Edit  
ERROR_RECURSELOOP = -52
Source   Edit  
ERROR_RECURSIONLIMIT = -53
Obsolete synonym Source   Edit  
ERROR_UNAVAILABLE = -54
Source   Edit  
ERROR_UNSET = -55
Source   Edit  
ERROR_UTF8_ERR1 = -3
Source   Edit  
ERROR_UTF8_ERR2 = -4
Source   Edit  
ERROR_UTF8_ERR3 = -5
Source   Edit  
ERROR_UTF8_ERR4 = -6
Source   Edit  
ERROR_UTF8_ERR5 = -7
Source   Edit  
ERROR_UTF8_ERR6 = -8
Source   Edit  
ERROR_UTF8_ERR7 = -9
Source   Edit  
ERROR_UTF8_ERR8 = -10
Source   Edit  
ERROR_UTF8_ERR9 = -11
Source   Edit  
ERROR_UTF8_ERR10 = -12
Source   Edit  
ERROR_UTF8_ERR11 = -13
Source   Edit  
ERROR_UTF8_ERR12 = -14
Source   Edit  
ERROR_UTF8_ERR13 = -15
Source   Edit  
ERROR_UTF8_ERR14 = -16
Source   Edit  
ERROR_UTF8_ERR15 = -17
Source   Edit  
ERROR_UTF8_ERR16 = -18
Source   Edit  
ERROR_UTF8_ERR17 = -19
Source   Edit  
ERROR_UTF8_ERR18 = -20
Source   Edit  
ERROR_UTF8_ERR19 = -21
Source   Edit  
ERROR_UTF8_ERR20 = -22
Source   Edit  
ERROR_UTF8_ERR21 = -23
Source   Edit  
ERROR_UTF16_ERR1 = -24
Source   Edit  
ERROR_UTF16_ERR2 = -25
Source   Edit  
ERROR_UTF16_ERR3 = -26
Source   Edit  
ERROR_UTF32_ERR1 = -27
Source   Edit  
ERROR_UTF32_ERR2 = -28
Source   Edit  
EXTENDED = 0x00000080'u32
Source   Edit  
EXTENDED_MORE = 0x01000000'u32
Source   Edit  
EXTRA_ALLOW_LOOKAROUND_BSK = 0x00000040'u32
Source   Edit  
EXTRA_ALLOW_SURROGATE_ESCAPES = 0x00000001'u32
Source   Edit  
EXTRA_ALT_BSUX = 0x00000020'u32
Source   Edit  
EXTRA_ASCII_BSD = 0x00000100'u32
Source   Edit  
EXTRA_ASCII_BSS = 0x00000200'u32
Source   Edit  
EXTRA_ASCII_BSW = 0x00000400'u32
Source   Edit  
EXTRA_ASCII_DIGIT = 0x00001000'u32
Source   Edit  
EXTRA_ASCII_POSIX = 0x00000800'u32
Source   Edit  
EXTRA_BAD_ESCAPE_IS_LITERAL = 0x00000002'u32
Source   Edit  
EXTRA_CASELESS_RESTRICT = 0x00000080'u32
Source   Edit  
EXTRA_ESCAPED_CR_IS_LF = 0x00000010'u32
Source   Edit  
EXTRA_MATCH_LINE = 0x00000008'u32
Source   Edit  
EXTRA_MATCH_WORD = 0x00000004'u32
Source   Edit  
EXTRA_NEVER_CALLOUT = 0x00008000'u32
Source   Edit  
EXTRA_NO_BS0 = 0x00004000'u32
Source   Edit  
EXTRA_PYTHON_OCTAL = 0x00002000'u32
Source   Edit  
EXTRA_TURKISH_CASING = 0x00010000'u32
Source   Edit  
FIRSTLINE = 0x00000100'u32
Source   Edit  
INFO_BSR = 3
Source   Edit  
INFO_DEPTHLIMIT = 21
Source   Edit  
INFO_FRAMESIZE = 24
Source   Edit  
INFO_HASCRORLF = 8
Source   Edit  
INFO_HEAPLIMIT = 25
Source   Edit  
INFO_JCHANGED = 9
Source   Edit  
INFO_JITSIZE = 10
Source   Edit  
INFO_MATCHEMPTY = 13
Source   Edit  
INFO_MATCHLIMIT = 14
Source   Edit  
INFO_MINLENGTH = 16
Source   Edit  
INFO_NAMECOUNT = 17
Source   Edit  
INFO_NAMETABLE = 19
Source   Edit  
INFO_NEWLINE = 20
Source   Edit  
INFO_SIZE = 22
Source   Edit  
JIT_COMPLETE = 0x00000001'u32
Source   Edit  
JIT_INVALID_UTF = 0x00000100'u32
Source   Edit  
JIT_PARTIAL_HARD = 0x00000004'u32
Source   Edit  
JIT_PARTIAL_SOFT = 0x00000002'u32
Source   Edit  
JIT_TEST_ALLOC = 0x00000200'u32
Source   Edit  
LITERAL = 0x02000000'u32
Source   Edit  
MATCH_INVALID_UTF = 0x00400000'u32
Source   Edit  
MATCH_UNSET_BACKREF = 0x00000200'u32
Source   Edit  
MULTILINE = 0x00000400'u32
Source   Edit  
NEVER_BACKSLASH_C = 0x00100000'u32
Source   Edit  
NEVER_UCP = 0x00000800'u32
Source   Edit  
NEVER_UTF = 0x00001000'u32
Source   Edit  
NEWLINE_ANY = 4
Source   Edit  
NEWLINE_CR = 1
Source   Edit  
NEWLINE_CRLF = 3
Source   Edit  
NEWLINE_LF = 2
Source   Edit  
NEWLINE_NUL = 6
Source   Edit  
NO_AUTO_CAPTURE = 0x00002000'u32
Source   Edit  
NO_AUTO_POSSESS = 0x00004000'u32
Source   Edit  
NO_DOTSTAR_ANCHOR = 0x00008000'u32
Source   Edit  
NO_JIT = 0x00002000'u32
Source   Edit  
NO_START_OPTIMIZE = 0x00010000'u32
Source   Edit  
NO_UTF_CHECK = 0x40000000'u32
Source   Edit  
NOTBOL = 0x00000001'u32
Source   Edit  
NOTEMPTY = 0x00000004'u32
Source   Edit  
NOTEMPTY_ATSTART = 0x00000008'u32
Source   Edit  
NOTEOL = 0x00000002'u32
Source   Edit  
PARTIAL_HARD = 0x00000020'u32
Source   Edit  
PARTIAL_SOFT = 0x00000010'u32
Source   Edit  
PCRE2_DATE = "2024-06-09"
Source   Edit  
PCRE2_MAJOR = 10
Source   Edit  
PCRE2_MINOR = 45
Source   Edit  
PCRE2_PRERELEASE = true
Source   Edit  
START_OPTIMIZE = 68
Source   Edit  
SUBSTITUTE_EXTENDED = 0x00000200'u32
Source   Edit  
SUBSTITUTE_GLOBAL = 0x00000100'u32
Source   Edit  
SUBSTITUTE_LITERAL = 0x00008000'u32
Source   Edit  
SUBSTITUTE_MATCHED = 0x00010000'u32
Source   Edit  
SUBSTITUTE_OVERFLOW_LENGTH = 0x00001000'u32
Source   Edit  
SUBSTITUTE_REPLACEMENT_ONLY = 0x00020000'u32
Source   Edit  
SUBSTITUTE_UNKNOWN_UNSET = 0x00000800'u32
Source   Edit  
SUBSTITUTE_UNSET_EMPTY = 0x00000400'u32
Source   Edit  
UCP = 0x00020000'u32
Source   Edit  
UNGREEDY = 0x00040000'u32
Source   Edit  
UNSET = 18446744073709551615'u
Source   Edit  
USE_OFFSET_LIMIT = 0x00800000'u32
Source   Edit  
UTF = 0x00080000'u32
Source   Edit  
ZERO_TERMINATED = 18446744073709551615'u
Source   Edit  

Procs

proc code_free(code: ptr Pcre) {.cdecl, importc: "pcre2_$1_8", ...raises: [],
                                 tags: [], forbids: [].}
Source   Edit  
proc compile(pattern: cstring; options: csize_t; flags: uint32;
             errorCode: ptr cint; offset: ptr csize_t; tableptr: pointer): ptr Pcre {.
    cdecl, importc: "pcre2_$1_8", ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc config(what: uint32; where: pointer): cint {.cdecl, importc: "pcre2_$1_8",
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc dfa_match(code: ptr Pcre; subject: cstring; length: csize_t;
               startoffset: csize_t; options: uint32; ovector: ptr MatchData;
               ovecsize: pointer; workspace: ptr cint; wscount: csize_t): cint {.
    cdecl, importc: "pcre2_$1_8", ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc get_ovector_count(ovector: ptr MatchData): uint32 {.cdecl,
    importc: "pcre2_$1_8", ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc get_ovector_pointer(ovector: ptr MatchData): ptr csize_t {.cdecl,
    importc: "pcre2_$1_8", ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc jit_compile(code: ptr Pcre; options: uint32): cint {.cdecl,
    importc: "pcre2_$1_8", ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc jit_match(code: ptr Pcre; subject: cstring; length: csize_t;
               startoffset: csize_t; options: uint32; ovector: ptr MatchData;
               ovecsize: pointer): cint {.cdecl, importc: "pcre2_$1_8",
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc match(code: ptr Pcre; subject: cstring; length: csize_t;
           startoffset: csize_t; options: uint32; ovector: ptr MatchData;
           ovecsize: pointer): cint {.cdecl, importc: "pcre2_$1_8", ...raises: [],
                                      tags: [], forbids: [].}
Source   Edit  
proc match_data_create(size: uint32; ctx: ptr GeneralContext): ptr MatchData {.
    cdecl, importc: "pcre2_$1_8", ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc match_data_create_from_pattern(code: ptr Pcre; ctx: ptr GeneralContext): ptr MatchData {.
    cdecl, importc: "pcre2_$1_8", ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc match_data_free(data: ptr MatchData) {.cdecl, importc: "pcre2_$1_8",
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc pattern_info(code: ptr Pcre; what: uint32; where: pointer): cint {.cdecl,
    importc: "pcre2_$1_8", ...raises: [], tags: [], forbids: [].}
Source   Edit