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:
Babar Javaid
|
Source |
|
Your Rating |
|
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.