Regular Expressions 101

Community Patterns

Matches MM/DD/YYYY for the years 1800 through 2099

0

Regular Expression
PCRE2 (PHP >=7.3)

/
^(((0[1-9]|1[012])\/(?!00|29)([012]\d)|(0[13-9]|1[012])\/(29|30)|(0[13578]|1[02])\/31)\/(18|19|20)\d{2}|02\/29\/((18|19|20)(0[48]|[2468][048]|[13579][26])|2000))$
/

Description

Source: https://stackoverflow.com/questions/8647893/regular-expression-leap-years-and-more

Seems to be valid for 1800 through 2099. Requires leading zeros. Matches MM/DD/YYYY format only.

Submitted by Andrew Macheret - a year ago