top | item 47168977

Regex is dead. We replaced it

9 points| hollowsolve | 3 days ago |matchlang.com

9 comments

order

andOlga|3 days ago

Do you genuinely, truly believe that "4 digits then "-" then 2 digits then "-" then 2 digits" is more readable than "\d{4}-\d{2}-\d{2}"? Do you think your walls of text won't make everyone's eyes glaze over a few lines in? More importantly, do you believe it's more writable? A lot of regex operations are ad-hoc, and being able to type them out quickly and look at them in a small text field at a glance is very important. And as far as coding is concerned, well, your thing is useless outside of the JS ecosystem, is it not?

Dead? Replaced?... Your toy is cute, but it's more suited as a regex generator, or perhaps parser/"explainer" (but we already have several well-known projects there) than a standalone tool.

AkshatM|3 days ago

The effort here is laudable, and this is cool! But your real competition isn't regexes, but parser combinator libraries. For cases where readability and matching matter, parser combinators are the go to. It's a bit difficult to see how this improves on that front.

hollowsolve|3 days ago

We built Match, a pattern matching language that compiles to WASM and replaces regex with readable grammars.

Instead of this: ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$

You write this:

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

Match features:

- WASM JIT + JS JIT: matches or beats native regex on most patterns

- Linear-time parsing, no backtracking, no ReDoS, ever

- Full parse trees with named extractions, not just match/no-match

- Zero dependencies, ~7KB, MIT licensed

- Composable grammars via modules

Website: https://matchlang.com

Performance: https://matchlang.com/docs/api/performance

GitHub: https://github.com/hollowsolve/Match

gus_massa|2 days ago

The preferred style here for the titles is more dry, something like "Matchlang: A pattern matching language that replaces regular expressions. Full parse trees, no ReDoS" or a shorter version like "Matchlang: A replacement for regular expressions. Full parse trees, no ReDoS".

If you write in the title "Regex is dead" people will get skeptical and ask for proofs.