Find the
signal in the
noise.
Three grammars, one syntax tree, one executor. Python's re,
the regex superset, and the ECMA-262 that a JSON Schema
means — with the same answers on every backend.
This box runs your browser's engine, so the page stays static. The showcase runs moonregex itself — type your own pattern over there.
One engine, many dialects.
A pattern is read by the grammar it was written in, lowered into one tree, and run by one backtracking machine — so switching grammars does not mean rewriting patterns.
Three grammars
Python's re, ECMA-262, and the lexmatch grammar the core library speaks. Named groups read as (?P<n>…), (?<n>…) and (?'n'…).
The hard parts
Backreferences, variable-length lookbehind, conditionals, recursion, atomic groups and possessive quantifiers — read, lowered, and executed.
(?(1)x|y) · (?>…) · (?R)Fuzzy matching
A bounded edit budget over a literal run: {e<=1}, {i<=1}, {d<=1}, {s<=1}, and the weighted form. The spent budget is reported on the match.
Shell globs
fnmatch, Glob and GlobSet translate *, **, ?, […] and {a,b} into patterns, with path-aware matching.
Unicode, from the UCD
\p{…} takes a category, script, block or binary property; \X matches one grapheme cluster; offsets count characters, not bytes. The tables come from moonucd.
Next to the core engine
A pattern the core engine can run lowers onto it as a @string.Regex; the combinators are the same five; a match carries both views.
Watch it decide.
A live playground that runs the library in your browser, and five more with the output it actually gave — a match walkthrough, one pattern in three spellings, the same string escaped by three grammars.
How a match is found
Step through (?P<w>\w+)\s+\1 over “go go no”, one match and one group at a time.
One pattern, three spellings
The same date, written for Python, for ECMA-262 and assembled from combinators — three values, one answer.
Compare → 03 · escapeThree grammars, three escapes
escape follows the grammar it is told to follow: a.b comes back as a\.b, \x61\.b or a\.b.
A small, honest surface.
The module functions mirror Python's re; a compiled
Pattern and a Match carry the rest. Every
line below is real MoonBit.
moon add moonbitstack/moonregex
then moon build --target all.