regular expression that does not allow 00:00 in valid time

Posted by RohiK under Regular Expressions on 12/20/2011 | Points: 10 | Views : 2393 | Status : [Member] | Replies : 1
Hi


I want to restrict time field that this will enter valid time from 12:01 - 23:59
but this will not allow 00:00

it will allow 00:01 too

how to do that?
plz help

Happy Programming!!
Rohi



Responses

Posted by: Naraayanan on: 12/29/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,
try this function
       public bool IsValidTime(string thetime)

{
Regex checktime =
new Regex(@"^(20|21|22|23|[01]d|d)(([:][0-5]d){1,2})$");

return checktime.IsMatch(thetime);
}


Regards,
Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
http://abaprocker.blogspot.com/

RohiK, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response