Skip to content

Instantly share code, notes, and snippets.

@frizbee
Last active January 19, 2024 08:55
  • Star 7 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save frizbee/5318c77d2084fa75cd00ea131399581a to your computer and use it in GitHub Desktop.
Regex for password must contain

Minimum eight characters, at least one letter and one number:

/^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$/

Minimum eight characters, at least one letter, one number and one special character:

/^(?=.*[A-Za-z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!%*#?&]{8,}$/

Minimum eight characters, at least one uppercase letter, one lowercase letter and one number:

/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$/

Minimum eight characters, at least one uppercase letter, one lowercase letter, one number and one special character:

/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/

Minimum eight and maximum 10 characters, at least one uppercase letter, one lowercase letter, one number and one special character:

/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,10}$/

Source:

regex lib

@Ibrahima-BA
Copy link

Super merci pour se partage.

@ENGKhaledAbdullah
Copy link

thanks a lot 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment