Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Regular Expression for a Password
#1
Not Solved
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..
Reply
#2
Not Solved
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.
Reply
#3
Not Solved
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
Pass
Else
Fail
End If

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
Reply
#4
Not Solved
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)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Need Any digit in xpath path using Regular expression Priyam 1 3,251 10-05-2016, 11:05 AM
Last Post: Ankur
  Regular expression to read two words in lowercase, uppercase and with and without spa sarahq49 1 3,194 04-09-2015, 01:56 AM
Last Post: sarahq49
  Regular expression and script optimisation Padmavathy 1 3,612 03-30-2015, 11:46 AM
Last Post: supputuri
  Regular expression in descriptive programming testernc 1 16,392 12-08-2014, 06:38 PM
Last Post: anshika.agarwal
  need a regular expression. anu05446 0 3,008 11-26-2014, 03:00 PM
Last Post: anu05446

Forum Jump:


Users browsing this thread: 1 Guest(s)