Skip to content

Instantly share code, notes, and snippets.

@westonwatson
Created December 10, 2013 20:05
Show Gist options
  • Save westonwatson/7897263 to your computer and use it in GitHub Desktop.
Save westonwatson/7897263 to your computer and use it in GitHub Desktop.
regex Patterns for Password Strength
// 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