2 ms·
I have a similar lib in JS that uses either regexps or plain strings for the leafs, and combinators to implement the various regexp operators. It is useful for
by pygy_ 9y ago
I have a similar lib in JS that uses either regexps or plain strings for the leafs, and combinators to implement the various regexp operators.
It is useful for maintainability. The regexp syntax was designed for a write-only scenario (the command line), but complex regexps quickly become unwieldy.
The regular grammar is all about composition, and the regexp syntax (in JS) doesn't allow one to store sub-expressions in variables for reuse and readability.
So this allows one to create regexps piece by piece, to write tests for the sub-expressions, etc...
https://github.com/pygy/compose-regexp.js https://github.com/pygy/compose-regexp.js