Regex processor module
Port of gb_regex with several bugfixes applied. This is a simple regex library and is fast to perform.
Supported Matching:
^ - Beginning of string
$ - End of string
. - Match one (anything)
| - Branch (or)
() - Capturing group
[] - Any character included in set
[^] - Any character excluded from set
+ - One or more (greedy)
+? - One or more (non-greedy)
* - Zero or more (greedy)
*? - Zero or more (non-greedy)
? - Zero or once
[BACKSLASH]XX - Hex decimal digit (must be 2 digits)
[BACKSLASH]meta - Meta character
[BACKSLASH]s - Whitespace
[BACKSLASH]S - Not whitespace
[BACKSLASH]d - Digit
[BACKSLASH]D - Not digit
[BACKSLASH]a - Alphabetic character
[BACKSLASH]l - Lower case letter
[BACKSLASH]u - Upper case letter
[BACKSLASH]w - Word
[BACKSLASH]W - Not word
[BACKSLASH]x - Hex Digit
[BACKSLASH]p - Printable ASCII character
–Whitespace–
[BACKSLASH]t - Tab
[BACKSLASH]n - New line
[BACKSLASH]r - Return carriage
[BACKSLASH]v - Vertical Tab
[BACKSLASH]f - Form feed
Classes
- struct zpl_re
- struct zpl_re_capture
Typedefs
-
using zpl_re = struct zpl_
re -
using zpl_re_capture = struct zpl_
re_ capture - using zplreError = enum zplreError
Functions
-
auto zpl_re_compile(zpl_
re* re, zpl_ allocator backing, char const* pattern, isize pattern_len) -> zplreError - Compile regex pattern.
-
auto zpl_re_compile_from_buffer(zpl_
re* re, char const* pattern, isize pattern_len, void* buffer, isize buffer_len) -> zplreError - Compile regex pattern using a buffer.
-
auto zpl_re_destroy(zpl_
re* re) -> void - Destroy regex object.
-
auto zpl_re_capture_count(zpl_
re* re) -> isize - Retrieve number of retrievable captures.
-
auto zpl_re_match(zpl_
re* re, char const* str, isize str_len, zpl_ re_ capture* captures, isize max_capture_count, isize* offset) -> b32 - Match input string and output captures of the occurence.
-
auto zpl_re_match_all(zpl_
re* re, char const* str, isize str_len, isize max_capture_count, zpl_ re_ capture** out_captures) -> b32 - Match all occurences in an input string and output them into captures. Array of captures is allocated on the heap and needs to be freed afterwards.