Skip to main content

Module pattern

Module pattern 

Source
Expand description

Lua pattern matching engine — a faithful port of lstrlib.c’s matcher. Pure functions over byte slices (stone candidate: no runtime types).

Structs§

Match
A successful match against a Lua pattern, with the captures it produced.
PatError
Error returned by the pattern matcher (malformed pattern, runaway depth, invalid %f frontier, etc.).

Enums§

Cap
One capture produced by a successful pattern match.

Functions§

anchor_split
Split a leading ^ anchor from the pattern body. The caller decides what the anchor means (find/match scan at most once; gsub/gmatch stop after the first position).
find
Scan from init for the first match (PUC str_find_aux without the plain fast path). A leading ^ anchors the search to init.
has_specials
Whether the pattern contains any pattern-special character (gsub/find fast path).
match_at
Try to match pat_body (already ^-stripped) at exactly position s, with no forward scan. Returns the Match (whose start == s) or None.
plain_find
Plain substring search (find with plain=true).