Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

regex for date 1

Status
Not open for further replies.

DotNetGnat

Programmer
Joined
Mar 10, 2005
Messages
5,548
Location
IN
guys, i have this regular expression for validating date...

Code:
(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d

so it validates correctly for any entered date in the format mm/dd/yyyy

but i also want it to validate m/d/yyyy

how do i change it...i mean if someone enter 12/4/2005 or 1/6/2005..it should be fine...but currently it looks for 12/04/2005 and 01/06/2005...

any help in modifying the regex?

-DNG
 
This should do it:
Code:
(0?[1-9]|1[012])[- /.](0?[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d
 
that did the trick...thanks

-DNG
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top