Regular Expressions 101

Community Patterns

Community Library Entry

2

Regular Expression
ECMAScript (JavaScript)

/
^([1-9]|(?=0)0[1-9]|(?=1)1[0-2])[-/.]([1-9]|(?=[0-2])[0-2][0-9]|(?=3)3[0-1])[-/.](\d{4}|\d{2})( ([1-9]|(?=[0-1])[0-1][0-9]|(?=2)2[0-4]):(?=[0-5])[0-5][0-9](:(?=[0-5])[0-5][0-9])?(a|p|A|P|am|pm|AM|PM)?)?$
/
gm

Description

Validates a US mm-dd-yy(yy) with an optional hh:mm:ss time.

Submitted by anonymous - 9 years ago