3 ms·
Regexes have one huge flaw: the syntax. If they had whitespace in them (like CoffeeScript), and required quoting the characters you were looking for (to disting
by TazeTSchnitzel 14y ago
Regexes have one huge flaw: the syntax. If they had whitespace in them (like CoffeeScript), and required quoting the characters you were looking for (to distinguish from syntax), then paired with a little syntax highlighting they would be far easier to read and write.
- pmahoney 14y agoRuby (borrowed from Perl and common in many regex impls I believe) has the "x" modifier to ignore whitespace and comments in literal regexes, for example: str = "2012-10-04T07:20:00" str =~ / (\d{4}) # four digit year - (\d{2}) # two digit month - (\d{2}) # two digit day T (\d{2}) # two digit hour : (\d{2}) # two digit min : (\d{2}) # two digit sec /x
- gmac 14y agoAnd if your implementation doesn't have it, it's not hard to add. E.g. for JS: http://blog.mackerron.com/2010/08/08/extended-multi-line-js-regexps/ http://blog.mackerron.com/2010/08/08/extended-multi-line-js-...
- andreasvc 14y agoAnd that flaw is compounded by subtly differing syntaxes among implementations, e.g., vim, python, grep, egrep.