![]() |
Regular Expression for a Password - 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 a Password (/Thread-Regular-Expression-for-a-Password) |
Regular Expression for a Password - ritesh - 08-04-2010 I am doing descriptive programming and i need to use Regular Expression for validating a password and the requirement are as follows: 1) Password should contain 8 characters. 2) Fifth character should be numeric. 3) Last 2 characters should be special charactes except % and ^ characters. Please let me know how to cover this. Thanks in advance.. RE: Regular Expression for a Password - guin.anirban - 08-04-2010 Pass the set of different password from the data table of the QTP or from external xls file and use these values in the script as a loop. RE: Regular Expression for a Password - venkatbatchu - 08-09-2010 Hi Ritesh, Lets assume ur password: pwd=venk1a;? You can do validation for this: 1. Password should be 8 characters Code: If len(pwd)=8 Then 2. To fetch the fiftch character use Mid function and pass "IsNumeric" function to find whether it is Numeric or Not 3. Right(pwd,1)<> "%" or "^" and Left(Right(pwd,2),1)<> "%" or "^". Please let me know for further clarification. Venkat.Batchu RE: Regular Expression for a Password - ngocvo3103 - 11-16-2010 Hi Ritesh, I'm a bit confused with your requirements 1. The password contains 8 characters, and fifth character should be numeric, so what should the first 4 characters be? Alphabet letters or numeric or special characters? 2. Also, what should the sixth character be? Anyway, I post my regular expression to solve your problem (hope I got you) Code: ^\w{4,4}\d\w[!@#$&*()-_=+\{\}\[\]|\\/;:'",.<>`~]{2,2}$ My regular expression will match with the password which has: - 8 characters in total - The first 4 characters should be Alphabet letters - The fifth character should be numeric - The sixth character should be Alphabet letters - The last 2 characters should be special character except % and ^ (I added some special characters on keyboard, you can add some more if you want) |