Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
Currently, I am working on receipt scanning app. I need a date from an extracted text:
So the date format is fixed. So how can I use regx to extract date?
dd/mm/yy
javascript extract date from string
A simple RegEx to capture the dates in this format would be
/\s\d\d\/\d\d\/\d\d\s/
and then use String.prototype.trim() to trim away leading and trailing whitespaces.
String.prototype.trim()
Using:
/\s[0123]\d\/[01]\d\/\d\d\s/
provides a little more validation, removing invalid months and days.
Add a comment
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
dd/mm/yyformat ?javascript extract date from stringhas loads of results