Regular expression

Posted by Sibin.rhythm under ASP.NET on 8/24/2009 | Views : 1262 | Status : [Member] | Replies : 5
I need regular expression for date in the given format
dd/mm/yyyy hh:mm am/pm

It will Never accept any other format
anybody help me????




Responses

Posted by: Lakhangarg on: 8/24/2009 [Member] [Moderator] Silver

Up
0
Down
Hi-

Use This for dd/mm/yyyy format
(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d


Thanks & Regards
Lakhan Pal Garg
http://lakhangarg.blogspot.com/


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

Posted by: Sibin.rhythm on: 8/24/2009 [Member] Starter

Up
0
Down
Thank you Lakhan Pal Garg ,

But I need expression not only for date but for Time also .

I need to type the textbox value in the following format

mm/dd/yyyy hh:mm am/pm

Wheather any body gives any other format of time and date , then the error message should display.

So please help me with the above format's regular expression....

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

Posted by: Lakhangarg on: 8/24/2009 [Member] [Moderator] Silver

Up
0
Down
Hi-

Check out this: ^((((([13578])|(1[0-2]))[\-\/\s]?(([1-9])|([1-2][0-9])|(3[01])))|((([469])|(11))[\-\/\s]?(([1-9])|([1-2][0-9])|(30)))|(2[\-\/\s]?(([1-9])|([1-2][0-9]))))[\-\/\s]?\d{4})(\s((([1-9])|(1[02]))\:([0-5][0-9])((\s)|(\:([0-5][0-9])\s))([AM|PM|am|pm]{2,2})))?$

for more detail visit:
http://regexlib.com/Search.aspx?k=Datetime&c=-1&m=-1&ps=20

Thanks & Regards
Lakhan Pal Garg
http://lakhangarg.blogspot.com/

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

Posted by: Sibin.rhythm on: 8/24/2009 [Member] Starter

Up
0
Down
Thankyou Mr.Lakhan Pal Garg

I am going to apply these code to my project.
I will contact u if there has more clarifications.

Thankyou once again

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

Posted by: Lakhangarg on: 8/24/2009 [Member] [Moderator] Silver

Up
0
Down
You are welcome..
no problem you can contact me at any time??
:)

Regards
Lakhan Pal Garg

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

Login to post response