Skip to content

Instantly share code, notes, and snippets.

@rezigned
Created April 23, 2012 05:50
Show Gist options
  • Save rezigned/2469020 to your computer and use it in GitHub Desktop.
Save rezigned/2469020 to your computer and use it in GitHub Desktop.
Regex for password validation
((?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%]).{7,20})
( # Start of group
(?=.*\d) # must contains one digit from 0-9
(?=.*[a-z]) # must contains one lowercase characters
(?=.*[A-Z]) # must contains one uppercase characters
(?=.*[@#$%]) # must contains one special symbols in the list "@#$%"
. # match anything with previous condition checking
{7,20} # length at least 7 characters and maximum of 20
)
# Refs: http://www.mkyong.com/regular-expressions/how-to-validate-password-with-regular-expression/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment