Page 1 of 1

Date Regex - dashes and slashes

Posted: 16 Jan 2024, 09:03
by tim mcentee
I am trying to match a date regex for mm/dd/yy or dd/mm/yyyy on the contents of an input field.

My regex is
^(0[0-9]|1[012])(\/)(0[0-9]|[12][0-9]|3[01])(\/)\d{2}$|(19|20)\d{2}$

This work fine for dates

My problem is that the gl format is n-nn-nnnn and this is being recognised as a date.

For some reason js regex is recognising a dash as a slash. ie - is being matched by (\/)

Any ideas

Tim