Friday, 7 December 2012

Regex for Strong Password

Regex for Strong Password

Here are few Regular Expressions for Strong Password:



Passwords will contain at least (1) upper case letter
Passwords will contain at least (1) lower case letter
Passwords will contain at least (1) number or special character
Passwords will contain at least (8) characters in length
Password maximum length should not be arbitrarily limited


  Special Characters - Not Allowed
    Spaces - Not Allowed
Minimum and Maximum Length of field - 6 to 12 Characters
Met by [a-zA-Z0-9@]{6,12}
Numeric Character - At least one character
Met by positive lookahead (?=.*\d)
At least one Capital Letter
Met by positive lookahead (?=.*[A-Z])
Repetitive Characters - Allowed only two repetitive characters

I am
not sure what you mean by this. The negative lookahead (?!.*(.)\1\1) makes sure that no character is allowed to appear more than two times in a row. Substring aa is okay, aaa is not.
Make it (?!.*(.+)\1\1) to reject repeated substrings of length more than one (like ababab) or add .* before \1 to reject non-continuous repeated appearances too.


-8 characters in length.
-At least 1 special
-At least 1 digit
-At least 1 upper
-At least 1 lower


Must be at least 10 characters , contain at least one one lower case letter, one upper case letter, one digit and one special character, Valid special characters (which are configurable) are -   @#$%^&+=


This regular expression will enforce a password to be at least 8 characters,
and to be a mix of letters and numbers. 



No comments:

Post a Comment

Thank You for Your Comments. We will get back to you soon.

back to top