Skip to content

Instantly share code, notes, and snippets.

@clohr
Last active May 11, 2017 18:45
Show Gist options
  • Save clohr/6b5b7b8aacc3be195248014de7002dfd to your computer and use it in GitHub Desktop.
Save clohr/6b5b7b8aacc3be195248014de7002dfd to your computer and use it in GitHub Desktop.
Password Regex: at least 1 lowercase letter, 1 uppercase letter, 1 number, 1 symbol, and 8-16 characters in length
const regex = /(?=^.{8,16}$)(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[\W])(?!.*\s).*$/g
const str = 'abcDeF#1'
const numMatches = str.match(regex).length
console.log('numMatches', numMatches)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment