4 ms·
For me, the biggest advantage of this sort of "library" approach is that instead of only being able to spedify regexes using literals you can treat them like ot
by ufo 13y ago
For me, the biggest advantage of this sort of "library" approach is that instead of only being able to spedify regexes using literals you can treat them like other values in the language: you can name subregexes, you can create functions that combine or modify regexes, etc.
I'm not sure the "builder pattern" in the OP does this well though...
- krainboltgreene 13y agoThoughts on doing it better? The DSL is just a wrapper for the objects.
- wyantb 13y agoI may as well make one suggestion along these lines ( implemented in a similar JS library I whipped up not too long ago: https://github.com/wyantb/js-regex https://github.com/wyantb/js-regex ). Macros! https://github.com/wyantb/js-regex#macros https://github.com/wyantb/js-regex#macros Given some named macro, whenever the user wants to use it, they use addMacro (or some analogous method).