Hacker News new | past | comments | ask | show | jobs | submit login

That's poor usage of regex. Try this:

    $ node
    > let XRegExp = require('xregexp');
    > XRegExp.exec('02-14-1924', XRegExp(`
        (?<day>  \\d{2} ) -
        (?<mon>  \\d{2} ) -
        (?<year> \\d{4} )
    `, 'x'))
    [ '02-14-19',
      '02',
      '14',
      '1924',
      index: 0,
      input: '02-14-1924',
      groups: undefined,
      day: '02',
      mon: '14',
      year: '1924' ]



Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: