Answer the question
In order to leave comments, you need to log in
How to write a regular expression to check a password?
It is necessary to check for password complexity so that there is at least one character from !"№;%:?*()_+=-.,<>~ any letter in any case and a number and password length from 6 characters to 21.
Is it possible to do this?
So far only this but doesn't work
public static boolean checkPassword(String s ){
Pattern p = Pattern.compile("^[a-z0-9_-]{6,21}$");
Matcher m = p .matcher(s);
return m.matches();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question