News for hackers. Stuff that matters.
Re:A human way to define regular expressions in Ruby by ufo on Thursday September 05, 2013 @02:44PM (#6336023)
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...

Re:A human way to define regular expressions in Ruby by krainboltgreene on Thursday September 05, 2013 @05:39PM (#6337251)
Thoughts on doing it better? The DSL is just a wrapper for the objects.
Re:A human way to define regular expressions in Ruby by wyantb on Thursday September 05, 2013 @06:48PM (#6337621)
I 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 ).

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).