Created
December 10, 2013 20:05
-
-
Save westonwatson/7897263 to your computer and use it in GitHub Desktop.
regex Patterns for Password Strength
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// STRONG PASSWORD | |
// Must have capital letter, numbers and lowercase letters | |
var strongRegex = new RegExp("^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$", "g"); | |
// MEDIUM PASSWORD | |
// Must have either capitals and lowercase letters or lowercase and numbers | |
var mediumRegex = new RegExp("^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g"); | |
// WEAK PASSWORD | |
// Must be at least 6 characters long | |
var okRegex = new RegExp("(?=.{6,}).*", "g"); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment