DEV Community

Cover image for Why I replaced regex with plain English
hollowsolve
hollowsolve

Posted on

Why I replaced regex with plain English

All developers know the relief of finally getting that regex to work. Then a few months later, nobody, including you, can read it.

I got tired of it, so I started working on Match: a pattern matching language where you describe what you're looking for in plain English.

Designing a language that reads like English seems straightforward, but keeping it organized and consistent was way more work than I anticipated.

The more walls I encountered, the more opinionated trade-offs had to be made. Should matching be greedy with backtracking, or greedy with commitment? I chose PEG semantics. First match wins, no backtracking. That one decision eliminates an entire class of security vulnerabilities (ReDoS) and makes every grammar predictable.

Should grammars be self-contained or composable? Both: you can write standalone grammars or import rules from modules with use "validators" (email, url).

Every choice came down to the same question: what would a developer expect to read six months from now?

If you're tired of writing regex that looks like a hashed paragraph, Match is free for open-source and education.

Try it at https://matchlang.com

Top comments (0)