Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
ECMAScript (JavaScript)

/
^(0[1-9]|1[0-2])-([1-9]|[12][0-9]|3[01])-(\d{4})$
/

Description

This is a regular expression for date in javascript. It validates the month between 01-12 (double digits only). It validates the day between 01-31 (double digits only). And enforces 4 digit year (no validation for range).

Submitted by Andrew Leonenko - 9 years ago