Community Patterns

Community Library Entry

0

Regular Expression
Created·2023-02-15 19:02
Flavor·PCRE2 (PHP)

/
^(((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))$
/
Open regex in editor

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