Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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


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




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: