#regex #lua-parser #lua

lua-pattern

Parser for Lua patterns and conversion to regular expressions

4 releases

0.1.3 Mar 1, 2025
0.1.2 Jul 6, 2023
0.1.1 May 24, 2023
0.1.0 May 24, 2023

#12 in #lua-parser

Download history 163/week @ 2025-11-05 123/week @ 2025-11-12 54/week @ 2025-11-19 42/week @ 2025-11-26 18/week @ 2025-12-03 43/week @ 2025-12-10 23/week @ 2025-12-17 87/week @ 2025-12-24 447/week @ 2025-12-31 57/week @ 2026-01-07 320/week @ 2026-01-14 350/week @ 2026-01-21 287/week @ 2026-01-28 199/week @ 2026-02-04 205/week @ 2026-02-11 226/week @ 2026-02-18

1,038 downloads per month
Used in 2 crates (via syntastica-query-preproce…)

GPL-3.0-only

44KB
896 lines

Usage

  • Lua patterns can be parsed to a tree with parse.
  • Parsed patterns can be converted to regex strings with try_to_regex.

For example:

use lua_pattern::{Class, PatternObject};

let tree = lua_pattern::parse("%l").unwrap();
assert_eq!(tree, [PatternObject::Class(Class::Lowercase)]);
#[cfg(feature = "to-regex")]
assert_eq!(
    lua_pattern::try_to_regex(&tree, false, false).unwrap(),
    "[a-z]"
);

lua-pattern

Parser for Lua patterns and conversion to regular expressions.

This crate provides a basic parser for Lua patterns, and, with the to-regex feature enabled, conversion to standard regular expressions as usable by the regex or fancy-regex crate.

Dependencies

~140–550KB
~13K SLoC