Tuesday, 24 April 2007

A Regular Expression for a Strong Password

Finally constructed a regex for a strong password I like:

(?=^.{8,}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$


A strong password is defined here as

1) Containing at least 1 upper case letter
2) Containing at least 1 lower case letter
3) Containing at least 1 number or special charachter
4) Containing at least 8 characters