Regular Expression to match a valid day in a date

后端 未结 10 1776
别那么骄傲
别那么骄傲 2020-12-11 01:45

I need help coming up with a regex to make sure the user enters a valid date The string will be in the format of mm/dd/yyyy

Here is what I have come up

10条回答
  •  醉话见心
    2020-12-11 02:12

    Regex for 0-31 day:

    0[1-9]|[12]\d|3[01]) without prefix 0 - when "1", "23"...

    ([1-9]|[12]\d|3[01]) with prefix 0 - when "01", "04"

    (0?[1-9]|[12]\d|3[01]) - with or without "0" - when ""

提交回复
热议问题