QTP Forums

Full Version: Regular Expression- Date
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Friends !!

I' working on a Web page which has lots of other objects which i can able to work with.

But, got a date object on the page of this type Wednesday, May 12, 2010 . I could not able to handle this correctly.

So far , I have regularized many dates successfully with only integers though. But now this has

strings, is there any one can able to help me out or correct me where i went wrrrrrrrrronooooooong

date on the page is like this Wednesday, May 12, 2010
I have regularized like this [Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday]/','/ [January|Febuary|March|April|May|June|July|August|September|October|November|Dece​mber] [0-3][0-3]/','/ [0-9][0-9][0-9][0-9]

waiting for the response !! Thanks for your help in advance guys !!!!
Code:
^((Mon|Tues|Wednes|Thur|Fri|Satur|Sun)day),[\s]((J(anuary|uly|une))|February|(M(arch|ay))|(A(pril|ugust))|((Sept|Nov|Dec)ember)​|October)[\s][0-9]{1,2},[\s][0-9]{4}

try this one.
^((Mon|Tues|Wednes|Thur|Fri|Satur|Sun)day),[\s]((J(anuary|uly|une))|February|(M(arch|ay))|(A(pril|ugust))|((Sept|Nov|Dec)ember)​|October)[\s][0-9]{1,2},[\s][0-9]{4}

I tried with the s included in Thursday as Thurs but did not work.

Well thanks for your help.
(05-13-2010 10:10 PM)defecttracer Wrote: [ -> ]^((Mon|Tues|Wednes|Thur|Fri|Satur|Sun)day),[\s]((J(anuary|uly|une))|February|(M(arch|ay))|(A(pril|ugust))|((Sept|Nov|Dec)ember)​|October)[\s][0-9]{1,2},[\s][0-9]{4}

I tried with the s included in Thursday as Thurs but did not work.

Well thanks for your help.

Might just be that your string contains more information than the date.

"Today is Thursday, May 20, 2010" would fail because of the "^" (caret) at the start of the regexp string. Remove the "^" (which means starts with) and try again.

You might try replacing the "^" with "[\w\s]+". That way the string can start with any word or whitespace character.
You can use DateValue function to make the string to a proper date value. And then use regular expression.
^((Mon|Tues|Wednes|Thurs|Fri|Satur|Sun)day),[\s]((J(anuary|uly|une))|February|(M(arch|ay))|(A(pril|ugust))|((Sept|Nov|Dec)ember)​|October)[\s][0-9]{1,2},[\s][0-9]{4}

This works. I have tested it in a regular expression validator.

Kiran Paul
kiran paul
Reference URL's