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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Date & Time Format dd-MMM-yyyy HH:mm:ss (24 hour)
Expression
^((31(?!([-])(Feb|Apr|June?|Sep|Nov)))|((30|29)(?!([-])Feb))|(29(?=([-])Feb([-])(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)))))|(0?[1-9])|1\d|2[0-8])([-])(Jan|Feb|Ma(r|y)|Apr|Ju(l|n)|Aug|Oct|(Sep|Nov|Dec))([-])((1[6-9]|[2-9]\d)\d{2}\s(([0-1]?[0-9])|([2][0-3])):([0-5]?[0-9])(:([0-5]?[0-9]))?)$
Description
This expression matches date and time (24 hour) both in format dd-MMM-yyyy HH:mm:ss. Only the short form of month is allowed i.e. Jan not January. The month names are also case sensitive. The second part of the time is optional. Also the leading zeros for day, hour, minute and seconds are optional.
Matches
31-Jan-2008 1:30:00|29-Feb-2008 01:45:45|30-Sep-2007 23:59
Non-Matches
31-Jan-2008 24:30:00|29-Feb-2007 01:45:45|3-Sep-2007 23:60:60
Author Rating: The rating for this expression. Babar Javaid
Source
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: How to make this case insensitive
Name: k
Date: 10/7/2013 4:58:02 PM
Comment:
Its matching case for months. So if users enter sep, the regex won't work. How to overcome case insensitvity.


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