R
R
Refri2015-11-03 07:51:00
Java
Refri, 2015-11-03 07:51:00

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

1 answer(s)
E
Eugene, 2015-11-03
@zolt85

The first link in Google for password validati...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question