Search code examples
node.jsregexdatedatefinder

Search String for dates and return as an array NodeJS


How would I go about searching a string for dates in NodeJS?

Is there a similar npm addon like https://pypi.org/project/datefinder?

Examples of the types of date formats

Chambersburg, PA, US), (June 1st $175)
(#Langley,B.C,CAN) (5/31/2019)
(#Raleigh, NC, USA), ($70 by May 31, 2019)
(#Guadalajara, JAL, Mexico), (June 2nd 2019)
(#Bowling Green, OH, US) (Repayment of $175 on 05/30 and $175 on 06/13)

Solution

  • There is a widely used JavaScript library called Moment. Check Moment Parsing Docs

    A few examples:

    moment("12/25/1995", "MM-DD-YYYY");
    moment('2012 juillet', 'YYYY MMM', 'fr');