Title |
Test
Find
Pattern Title
|
Expression |
^((([0]?[1-9]|1[0-2])(:|\.)[0-5][0-9]((:|\.)[0-5][0-9])?( )?(AM|am|aM|Am|PM|pm|pM|Pm))|(([0]?[0-9]|1[0-9]|2[0-3])(:|\.)[0-5][0-9]((:|\.)[0-5][0-9])?))$ |
Description |
Matches times seperated by either : or . will match a 24 hour time, or a 12 hour time with AM or PM specified. Allows 0-59 minutes, and 0-59 seconds. Seconds are not required. |
Matches |
1:01 AM | 23:52:01 | 03.24.36 AM |
Non-Matches |
19:31 AM | 9:9 PM | 25:60:61 |
Author |
Rating:
Not yet rated.
Steve Valaitis
|
Source |
|
Your Rating |
|
Title: Simplify AM/PM with more matches
Name: Adam Zuckerman
Date: 6/12/2012 2:26:18 PM
Comment:
Replace (AM|am|aM|Am|PM|pm|pM|Pm) with (?i:(a|p)(\.)?( )?m(\.)?) and you will match any combination of am/pm (case insensitive) including with periods and spaces (i.e., AM, A.M., or A. M.).
Title: Can I modify it to just the hour?
Name: Steve
Date: 11/23/2011 2:50:45 PM
Comment:
How about 12AM? Could you show me how I can modify it, so that I can only match it by the hour?
Title: Can I modify it to just the hour?
Name: Steve
Date: 11/23/2011 2:49:58 PM
Comment:
How about 12AM? Could you show me how I can modify it, so that I can only match it by the hour?
Title: Perfect
Name: Paul
Date: 11/1/2011 4:05:30 PM
Comment:
Just what I needed for many possible formats. Works perfectly in .Net 4 C#.
Title: Perfect
Name: Paul
Date: 11/1/2011 4:05:21 PM
Comment:
Just what I needed for many possible formats. Works perfectly in .Net 4 C#.
Title: there're something wrong?
Name: jackie
Date: 9/25/2010 4:36:18 AM
Comment:
how about 12:30AM?i run it in perl and got the Matched result. i don't understand it...
Title: Simplify time expression
Name: PaulR
Date: 11/15/2004 11:16:25 AM
Comment:
Replace
"AM|am|aM|Am|PM|pm|pM|Pm"
with:
"[aApP][mM]"