Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Regular Expression for a Password
08-04-2010, 10:33 AM
Post: #1
Regular Expression for a Password

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..
Find all posts by this user
Quote this message in a reply
08-04-2010, 11:29 AM
Post: #2
RE: Regular Expression for a Password
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.
Find all posts by this user
Quote this message in a reply
08-09-2010, 03:18 PM
Post: #3
RE: Regular Expression for a Password
Hi Ritesh,
Lets assume ur password: pwd=venk1a;?
You can do validation for this:
1. Password should be 8 characters
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

Regards,
Venkat
Find all posts by this user
Quote this message in a reply
11-16-2010, 03:54 PM (This post was last modified: 11-16-2010 03:55 PM by ngocvo3103.)
Post: #4
RE: Regular Expression for a Password
(08-04-2010 10:33 AM)ritesh Wrote:  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..

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)
Find all posts by this user
Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Regular expression for this string falvi 2 238 04-30-2012 11:14 AM
Last Post: falvi
  regular expression rjkmr.aiht 0 146 04-27-2012 11:37 AM
Last Post: rjkmr.aiht
  Regular Expression samverma 3 348 03-31-2012 01:21 AM
Last Post: samverma
  Square Bracket Issue - Regular Expression kapsig431 2 281 03-29-2012 08:38 PM
Last Post: kapsig431
  Regular Expression for time in 24 hour format with out colon Pallavi 3 431 03-13-2012 11:29 AM
Last Post: sshukla12

Forum Jump:


User(s) browsing this thread: 1 Guest(s)