what will be the regular expression for allowing data to be entered in texbox in following format
11:00 am
01:59 pm
05:47 AM
note am pm can be both capital and small
hours shold be always 2 digit i.e, 01 and not 1
regex for time
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

VulpesRank #55 · 29.2K reputationPosted Feb 10, 2012, 2:01 AM EST
string regExp = @"^(0[1-9]|1[0-2]):[0-5][0-9] (am|pm|AM|PM)$";
or, if you want to allow for mixed case on the AM/PM (i.e. aM, Pm etc):
string regExp = @"^(0[1-9]|1[0-2]):[0-5][0-9] (?i)(am|pm)$";
nishant ranjanRank #4,961 · 317 reputationPosted Feb 10, 2012, 2:17 AM EST