If you need to check whether a password is alphanumeric or not using regex try this Java Solution :

boolean passwordOnlyAlphaNumericCheck = false;
  passwordOnlyAlphaNumericCheck = true;

what is the difference between login.getPassword().matches(“[0-9a-zA-Z]*”); and login.getPassword().matches(“[0-9a-zA-Z]”); ?

Answer : The .matches(“[0-9a-zA-Z]”) will only return true if the whole string contains just 1 digit or letter. The * in [0-9a-zA-Z]* will allow an empty string, or a string having zero or more letters/digits.

Laisser un commentaire