Tuesday, November 18, 2008

Regular expressions for passwords

This is a link post for some of the regular expressions that can be used for passwords.  Specifically, you can use them for asp.net's passwordStrengthRegularExpression. Note: Be sure to test them *before* you use them in a production app. The table indicates the minimum length, if it requires at least one upper, lower, digit or special character.

Expression Len Upper Lower Digit Special
^.*(?=.{10,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=]).*$ 10 Y Y Y Y
^.*(?=.{8,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).*$ 8 Y Y Y N
^.*(?=.{10,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=]).*$ 10 Y Y Y Y

No comments: