Skip to content

Instantly share code, notes, and snippets.

@g-rohit
Created June 30, 2019 18:38
Show Gist options
  • Save g-rohit/59009e6bd21a33deb2ed36d49332d03b to your computer and use it in GitHub Desktop.
Save g-rohit/59009e6bd21a33deb2ed36d49332d03b to your computer and use it in GitHub Desktop.
Reg ex for password
You may use this regex with multiple lookahead assertions (conditions):
^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,}$
This regex will enforce these rules:
At least one upper case English letter, (?=.*?[A-Z])
At least one lower case English letter, (?=.*?[a-z])
At least one digit, (?=.*?[0-9])
At least one special character, (?=.*?[#?!@$%^&*-])
Minimum eight in length .{8,} (with the anchors)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment