Regular Expression to match a valid day in a date

后端 未结 10 1768
别那么骄傲
别那么骄傲 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:10

    Regex for 0-31:

    (0[1-9]|[12]\d|3[01])
    

    Or if you don't want days with a preceding zero (e.g. 05):

    ([1-9]|[12]\d|3[01])
    

提交回复
热议问题