Micro Focus QTP (UFT) Forums
Regular Expression for date - 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 Expression for date (/Thread-Regular-Expression-for-date)



Regular Expression for date - newqtp - 01-19-2008

Can you anyone tell a regular expression to check that a date entered has a valid format of MM/DD/200Y ?


RE: Regular Expression for date - Ankur - 01-19-2008

(0[1-9]|1[012])[//](0[1-9]|[12][0-9]|3[01])[//]200[0-9]$


RE: Regular Expression for date - vasu_tj3 - 01-31-2008

Hi Ankur,

i am regular user of your blog.I found it very useful.I am learning QTP...
Can u please explain this (0[1-9]|1[012]) expression.

Thank you..


RE: Regular Expression for date - Ankur - 01-31-2008

well...the OP has asked for the format MM/DD/200Y

(0[1-9]|1[012]) --- This covers the MM part of the whole expression. [1-9] means any numeral between 1 and 9. [012] means either 0 or 1 or 2

| separator stands for "OR".

So when you group the whole expression it mean either look out for month from 01 to 09 or 10 or 11 or 12 month. So this covers the whole range of months available (from Jan to Dec)