This is a Rust binding to Lua string patterns, using the original code from Lua 5.2.
Although not regular expressions (they lack alternation) they are a powerful and lightweight way to process text. Please note that they are not UTF-8-aware, and in fact can process arbitrary binary data.
LuaPattern
can be created from a string or a byte slice, and has
methods which are similar to the original Lua API. Please see
the README
for more discussion.
LuaPattern implements the public API.
Examples
extern crate lua_patterns;
let mut m = new;
let text = "hello one two";
assert!;
let r = m.range;
assert_eq!;
assert_eq!;
Collecting captures from a match:
extern crate lua_patterns;
let text = " hello one";
let mut m = new;
// allocates a vector of captures
let v = m.captures;
assert_eq!;
let mut v = Vec new;
// writes captures into preallocated vector
if m.capture_into