Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Regular Exp for mm/dd/yyyy date format
#1
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi Ankur,

Can you please tell me how i will user regular expression for date which has the mm/dd/yyyy format.

I have to validate using regular expression.

Thanks,
Dheeraj
#2
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi Dheeraj,

use the below pattern to match your date format mm/dd/yyyy

Code:
sPattern="(0[1-9]|1[012])[ /](0[1-9]|[12][0-9]|3[01])[ /]([0-9]{4})"

Thanks,
Azeem
#3
Solved: 11 Years, 3 Months, 3 Weeks ago
I can suggest you the pattern for your required format
you can use
Code:
(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d

#4
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi Saket,

Why your pattern is getting failed for Valied dates below.

09/23/1247 - Fails
03/12/2214 - Fails

Could you please explain? and make sure post doesnt have such requirement to match only years (1900 - 2099).

Thanks,
Azeem
#5
Solved: 11 Years, 3 Months, 3 Weeks ago
Yes definitely it would fail because, you see at the end where I have set pattern for year I have mentioned (19|20), this will allow you to compare only for year 1900 to 2999, But this can be manipulated as per your requirement. try replacing (19|20)\d\d with \d{4}.

what do you mean when you say ' make sure post doesnt have such requirement to match only years (1900 - 2099).'? we are here to help you with our best, whatever we have we can suggest only. I dont think we should fulfill the exact requirement, let the guy do some on his own. whatever I have posted is just a suggestion.
Apologies if I posted something wrong.

#6
Solved: 11 Years, 3 Months, 3 Weeks ago
@Saket & @Azeem : Cool Guys !!!Smile

All in all, We all are on the same page.
#7
Solved: 11 Years, 3 Months, 3 Weeks ago
@ Everyone - Please restrict yourselves from Indulging in Destructive Arguments. We are here to help all with whatever we know and nobody is born with the right solution. Please Understand that providing the Exact solution never eliminates the Root cause of the problem but only prompts for more desperation. A clue or a lead is what necessarily helps anyone to learn.

On a thought , Please stop spitting venom on your co-members of the forum. If there is something wrong please notify the moderator or post a comment which does not hurt anyone. Mistakes are a mode to learn more and not to be used to suppress someone.

As the answer has been provided there is no requirment for anyone to continue arguing or posting on this thread.

Thread locked !!
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to click on a date button? Parthasit033 0 1,940 09-06-2017, 01:49 AM
Last Post: Parthasit033
  Regular Exp Issue Jyobtech 2 4,281 09-28-2012, 12:08 PM
Last Post: Jyobtech
  Regular Expression for time in 24 hour format with out colon Pallavi 3 4,982 03-13-2012, 11:29 AM
Last Post: sshukla12
  Regular expression for date rajaselvan.d 1 3,557 02-09-2012, 08:48 AM
Last Post: rajpes
  REgular Expression for Dynamic Date nulupraveen 2 5,549 06-07-2011, 03:26 PM
Last Post: surya_7mar

Forum Jump:


Users browsing this thread: 1 Guest(s)