Regular Expressions 101

Community Patterns

Community Library Entry

7

Regular Expression
ECMAScript (JavaScript)

/
^\d{4}-(((0[13578]|1[02])-(0[1-9]|[12]\d|3[0-1]))|(02-(0[1-9]|[12]\d))|((0[469]|11)-(0[1-9]|[12]\d|30)))$
/
gm

Description

Besides leap year handling, this takes care of date validation in the yy-mm-dd format.

Submitted by anonymous - 9 years ago