Example — matching an email address:
email: username then "@" then domain
username: one or more of (letter, digit, ".", "_", "-")
domain: one or more of (letter, digit, "-") then "." then between 2 and 6 letters
Key differences from regex:
- Human-readable grammar syntax - Full parse trees with named extractions - No backtracking, no ReDoS by design - Composable grammar modules (use "module" (rule1, rule2)) - Zero dependencies, ~15KB
Available on npm (@hollowsolve/match). Docs, playground, and examples on the site.