Tuesday, January 31, 2006

 
Clock Time Regex

My own work:

^(0[0-9]|\d|1[0-2]):([0-5]\d)\s+(am|pm)$

This verifies if the time you put in matches the 12 hour clock. It works in every flavor of Regex, from the Perl/LAMP engine to the Java version to the Javascript version.

Below is a 24 hour version:

^([0-1]\d|\d|2[0-4]):([0-5]\d)$

If I get any comments to this blog, I'll add a seconds verifier.

Comments: Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?