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
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Feb 10, 2012, 7:01 AM
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 ranjanPosted Feb 10, 2012, 7:17 AM