package core:text/match
Index
Constants (5)
Variables (1)
Procedures (42)
- capture_to_close
- check_capture
- class_end
- end_capture
- find_aux
- gfind
- gmatch
- gsub_allocator
- gsub_builder
- gsub_with
- index_special
- is_alnum
- is_cont
- is_graph
- is_xdigit
- lmem_find
- match
- match_balance
- match_bracket_class
- match_capture
- match_class
- match_default
- matcher_capture
- matcher_capture_raw
- matcher_captures_slice
- matcher_find
- matcher_gmatch
- matcher_init
- matcher_match
- matcher_match_iter
- max_expand
- min_expand
- pattern_case_insensitive_allocator
- pattern_case_insensitive_builder
- push_captures
- push_onecapture
- single_match
- start_capture
- utf8_advance
- utf8_next
- utf8_peek
- utf8_prev
Procedure Groups (2)
Types
Error ¶
Error :: enum int { OK, OOB, Invalid_Capture_Index, Invalid_Pattern_Capture, Unfinished_Capture, Malformed_Pattern, Rune_Error, Match_Invalid, }
Related Procedures With Returns
Gsub_Proc ¶
Related Procedures With Parameters
Match ¶
Related Procedures With Returns
Match_State ¶
Related Procedures With Parameters
Matcher ¶
Matcher :: struct { haystack: string, pattern: string, captures: [32]Match, captures_length: int, offset: int, err: Error, // changing content for iterators iter: string, iter_index: int, }
Matcher helper struct that stores optional data you might want to use or not as lua is far more dynamic this helps dealing with too much data this also allows use of find/match/gmatch at through one struct
Related Procedures With Parameters
- matcher_capture
- matcher_capture_raw
- matcher_captures_slice
- matcher_find
- matcher_match
- matcher_match_iter
Related Procedures With Returns
Constants
CAP_POSITION ¶
CAP_POSITION :: -2
CAP_UNFINISHED ¶
CAP_UNFINISHED :: -1
MAX_CAPTURES ¶
MAX_CAPTURES :: 32
Variables
SPECIALS_TABLE ¶
SPECIALS_TABLE: [256]bool = …
SPECIALS := "^$*+?.([%-" all special characters inside a small ascii array
Procedures
capture_to_close ¶
capture_to_close :: proc(ms: ^Match_State) -> (int, Error) {…}
check_capture ¶
check_capture :: proc(ms: ^Match_State, l: rune) -> (int, Error) {…}
class_end ¶
class_end :: proc(ms: ^Match_State, p: int) -> (step: int, err: Error) {…}
end_capture ¶
end_capture :: proc(ms: ^Match_State, s, p: int) -> (res: int, err: Error) {…}
find_aux ¶
find_aux :: proc(haystack: string, pattern: string, offset: int, allow_memfind: bool, matches: ^[32]Match) -> (captures: int, err: Error) {…}
find a pattern with in a haystack with an offset allow_memfind will speed up simple searches
gfind ¶
gfind :: proc(haystack: ^string, pattern: string, captures: ^[32]Match) -> (res: string, ok: bool) {…}
iterative find with zeroth capture only
gmatch ¶
gmatch :: proc(haystack: ^string, pattern: string, captures: ^[32]Match) -> (res: string, ok: bool) {…}
iterative matching which returns the 0th/1st match rest has to be used from captures
gsub_allocator ¶
gsub_allocator :: proc(haystack: string, pattern: string, replace: string, allocator := context.allocator) -> string {…}
uses temp builder to build initial string - then allocates the result
gsub_builder ¶
gsub_builder :: proc(builder: ^strings.Builder, haystack: string, pattern: string, replace: string) -> string {…}
gsub with builder, replace patterns found with the replace content
gsub_with ¶
call a procedure on every match in the haystack
index_special ¶
helper call to quick search for special characters
match_balance ¶
match_balance :: proc(ms: ^Match_State, s, p: int) -> (unused: int, err: Error) {…}
match_bracket_class ¶
match_bracket_class :: proc(ms: ^Match_State, c: rune, p, ec: int) -> (sig: bool, err: Error) {…}
match_capture ¶
match_capture :: proc(ms: ^Match_State, s: int, char: rune) -> (res: int, err: Error) {…}
match_default ¶
match_default :: proc(ms: ^Match_State, s, p: int) -> (unused: int, err: Error) {…}
matcher_capture ¶
matcher_capture :: proc(matcher: ^Matcher, index: int, loc := #caller_location) -> string {…}
get the capture at the "correct" spot, as spot 0 is reserved for the first match
matcher_capture_raw ¶
matcher_capture_raw :: proc(matcher: ^Matcher, index: int, loc := #caller_location) -> Match {…}
get the raw match out of the captures, skipping spot 0
matcher_captures_slice ¶
get a slice of all valid captures above the first match
matcher_find ¶
find the first match and return the byte start / end position in the string, true on success
matcher_gmatch ¶
matcher_gmatch :: matcher_match_iter
iteratively match the haystack till it cant find any matches
matcher_init ¶
init using haystack & pattern and an optional byte offset
matcher_match ¶
find the first match and return the matched word, true on success
matcher_match_iter ¶
iteratively match the haystack till it cant find any matches
max_expand ¶
max_expand :: proc(ms: ^Match_State, s, p, ep: int) -> (res: int, err: Error) {…}
min_expand ¶
min_expand :: proc(ms: ^Match_State, s, p, ep: int) -> (res: int, err: Error) {…}
pattern_case_insensitive_allocator ¶
pattern_case_insensitive_allocator :: proc(pattern: string, cap: int = 256, allocator := context.allocator) -> (res: string) {…}
pattern_case_insensitive_builder ¶
pattern_case_insensitive_builder :: proc(builder: ^strings.Builder, pattern: string) -> (res: string) {…}
rebuilds a pattern into a case insensitive pattern
single_match ¶
single_match :: proc(ms: ^Match_State, s, p, ep: int) -> (matched: bool, schar_size: int, err: Error) {…}
start_capture ¶
start_capture :: proc(ms: ^Match_State, s, p, what: int) -> (res: int, err: Error) {…}
utf8_advance ¶
find the first utf8 charater and its size and advance the index return an error if the character is an error
utf8_peek ¶
find the first utf8 charater and its size, return an error if the character is an error
Procedure Groups
gsub ¶
gsub :: proc{ gsub_builder, gsub_allocator, }
pattern_case_insensitive ¶
pattern_case_insensitive :: proc{ pattern_case_insensitive_builder, pattern_case_insensitive_allocator, }
Source Files
Generation Information
Generated with odin version dev-2024-11 (vendor "odin") Windows_amd64 @ 2024-11-20 21:11:51.604253000 +0000 UTC