Regular Exp for mm/dd/yyyy date format - Printable Version +- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums) +-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP) +--- Forum: UFT / QTP Regular Expressions (https://www.learnqtp.com/forums/Forum-UFT-QTP-Regular-Expressions) +--- Thread: Regular Exp for mm/dd/yyyy date format (/Thread-Regular-Exp-for-mm-dd-yyyy-date-format) |
Regular Exp for mm/dd/yyyy date format - dheerajm - 08-27-2009 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 RE: Regular Exp for mm/dd/yyyy date format - azeem - 08-27-2009 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 RE: Regular Exp for mm/dd/yyyy date format - Saket - 08-27-2009 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 RE: Regular Exp for mm/dd/yyyy date format - azeem - 08-27-2009 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 RE: Regular Exp for mm/dd/yyyy date format - Saket - 08-27-2009 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. RE: Regular Exp for mm/dd/yyyy date format - sreekanth chilam - 08-28-2009 @Saket & @Azeem : Cool Guys !!! All in all, We all are on the same page. RE: Regular Exp for mm/dd/yyyy date format - basanth27 - 08-28-2009 @ 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 !! |