My password condition is, minimum 8 characters, minimum one special character, minimum one numeric
For this I wrote a simple class to verify, but eventually fails.
Any help is highly appreciated.
public class PasswordVerifier {
private static final String SPECIAL_CHARACTERS = "(`~!@#$%^&*()_+=-][;'/.,\\<>?|:\"}{)";
public static void main(String... args) {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
try {
String password = in.readLine();
if(!password.matches("^.*(?=.{8,})(?=.*[0-9])(?=.*[SPECIAL_CHARACTERS]).*$")){
System.out.println("Password does not satisfy compliant");
} else {
System.out.println("Yes.. gets through");
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
This might work for your requirement:
The regex specifies: