3 ms·
> This library turns it into self-docummenting code, which is incredibly valuable. The problem is that for anyone who knows how regexps work, this library prov
by saidajigumi 13y ago
> This library turns it into self-docummenting code, which is incredibly valuable.
The problem is that for anyone who knows how regexps work, this library provides an obfuscation layer. I personally prefer the free-spacing regexp support[1] found in a number of popular parsers. It lets you write a complicated regexp in small and/or indented chunks across multiple lines, including comments. This provides as much or more documentation than this "self-documenting" form and allows the full power of the regexp engine (which big regexps often seem to need). I've occasionally had to work out some pretty gnarly regexps, but when written in two-column code/comments form they end up being pretty understandable and maintainable.
[1] Example from the Ruby docs. IIRC, Python and a few other parsers have similar support: http://www.ruby-doc.org/core-1.9.3/Regexp.html#label-Free-Spacing+Mode+and+Comments http://www.ruby-doc.org/core-1.9.3/Regexp.html#label-Free-Sp...