Date Regex - dashes and slashes

Use this Forum to post your “How to …” questions about your use of aXes. This is not a technical support forum. Both the aXes Support Team at LANSA and other aXes customers may answer your questions. LANSA cannot guarantee the accuracy of any information posted by customers.

Moderator: jeanmichel

Post Reply
tim mcentee
Posts: 36
Joined: 26 Jul 2017, 13:20

Date Regex - dashes and slashes

Post by tim mcentee » 16 Jan 2024, 09:03

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

Post Reply