Regular Expression to match valid dates

后端 未结 15 1823
庸人自扰
庸人自扰 2020-11-22 04:48

I\'m trying to write a regular expression that validates a date. The regex needs to match the following

  • M/D/YYYY
  • MM/DD/YYYY
  • Single digit mon
15条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-22 05:21

    if you didn't get those above suggestions working, I use this, as it gets any date I ran this expression through 50 links, and it got all the dates on each page.

    ^20\d\d-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(0[1-9]|[1-2][0-9]|3[01])$ 
    

提交回复
热议问题