Expand description
Lua pattern matching engine — a port of lstrlib.c’s matcher. Pure functions over byte slices (stone candidate: no runtime types).
The matcher is the 5.2+ one (explicit pattern end, matchdepth bound);
Flavor carries the few places where older dialects differ. 5.1’s
NUL-terminated patterns are the caller’s business: it passes the pattern
cut at the first NUL.
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
%ffrontier, 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 stops after the first position). - find
- Scan from
initfor the first match (PUC str_find_aux without the plain fast path). A leading^anchors the search toinit. - has_
specials - Whether the pattern contains a byte from PUC’s
SPECIALS; a pattern without one is searched for as plain text. - match_
at - Try to match
pat_body(already^-stripped) at exactly positions, with no forward scan. Returns the Match (whosestart == s) or None; a capture left open by a successful match is an error. - plain_
find - Plain substring search (find with plain=true).