RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
^(([0]?[1-9]|1[0-2])/([0-2]?[0-9]|3[0-1])/[1-2]\d{3})? ?((([0-1]?\d)|(2[0-3])):[0-5]\d)?(:[0-5]\d)? ?(AM|am|PM|pm)?$
Description
Matches variations on date/time/AM-PM. Must have 4 digit year, but everything else is open. Restrictions are: 4 digit year, months 1-12, hours 1-23, minutes and seconds 1-59, any case of AM and PM. If this don't woik, I wrote it, lemmy know.
Matches
12/30/2002 | 12/30/2002 9:35 pm | 12/30/2002 19:35:02
Non-Matches
18/22/2003 | 8/12/99 | 8/22/2003 25:00
Author Rating: Not yet rated. Michael Gaertner
Source Various addmixures of mgaert and the RegExLib.com posse.
Your Rating
Bad Good

Enter New Comment

Title
 
Name
 
Comment
 
Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Title: Ok Expression
Name: EdwardQ
Date: 12/9/2009 2:51:13 PM
Comment:
This expression also matches a space, and AM and PM And 12:05


Title: Excellent expression!
Name: D Mudge
Date: 7/21/2006 9:32:45 AM
Comment:
This is an excellent expression for validating basic date/time combinations. Thank you very much!


Copyright © 2001-2018, RegexAdvice.com | ASP.NET Tutorials