0

Currently, I am working on receipt scanning app. I need a date from an extracted text:

enter image description here

So the date format is fixed. So how can I use regx to extract date?

Gajjar Tejas
  • 188
  • 5
  • 20

1 Answers1

2

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.

Using:

/\s[0123]\d\/[01]\d\/\d\d\s/

provides a little more validation, removing invalid months and days.

Dane
  • 9,242
  • 5
  • 33
  • 56