Skip to content

Instantly share code, notes, and snippets.

@tmaxxdd
Created July 31, 2019 10:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmaxxdd/f5556c770bb5d8256a95b2afbcde4cb0 to your computer and use it in GitHub Desktop.
Save tmaxxdd/f5556c770bb5d8256a95b2afbcde4cb0 to your computer and use it in GitHub Desktop.
private boolean isPasswordValid(CharSequence pass) {
/*
^ # start-of-string
(?=.*[0-9]) # a digit must occur at least once
(?=.*[a-z]) # a lower case letter must occur at least once
(?=.*[A-Z]) # an upper case letter must occur at least once
(?=.*[@#$%^&+=]) # a special character must occur at least once
.{8,} # anything, at least eight places though
$ # end-of-string
*/
return pass.toString().matches("^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=]).{8,}$");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment