4 ms·
Ruby (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:
by pmahoney 14y ago
Ruby (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-...