Regular Expressions 101

Community Patterns

Community Library Entry

4

Regular Expression
PCRE (PHP <7.3)

/
^20(((([248][048])|([13579][26]))\/(((0[13578]|1[02])\/([0-2][0-9]|3[01]))|((0[469]|11)\/([0-2][0-9]|30))|(02\/([0-2][0-9]))))|((([248][1-35-79])|([13579][013-57-9]))\/(((0[13578]|1[02])\/([0-2][0-9]|3[01]))|((0[469]|11)\/([0-2][0-9]|30))|(02\/(((0|1)[0-9])|(2[0-8]))))))$
/

Description

Regex following "ISO 8601" without hour : allowing only month 1 to 12, the day of 1 to 31 for the months of 31 days, the months from 1 to 30 for the months of 30 days, the day of 1 to 28 for February, and the day from 1 to 29 for February of leap years

Submitted by Sara DULMAR - 9 years ago