Skip to main content

gmatch

Function gmatch 

Source
pub fn gmatch(state: &mut LuaState) -> Result<usize, LuaError>
Expand description

string.gmatch(s, pattern [, init]) — return an iterator for all matches.

Builds the iterator closure consumed by gmatch_aux (5.3+) or gmatch_aux_legacy (5.1/5.2): the source and pattern become traced upvalues 1 and 2, and a fresh userdata holding a [GMatchIterState] becomes upvalue 3 (the mutable byte positions). The empty-match-dedup seam is bound at creation by picking the closure, so the per-match step never branches on it (see [gmatch_step]).