My test method is here and all the other inputs are fine but the problem is can't test on the string containing \
backslash character,
public static void main(String[] args) {
String reg2 = "^[a-zA-Z0-9@\\#$%&*()_+\\]\\[';:?.,!^-]{8,}$";
System.out.println("".matches(reg2));
System.out.println("Pass".matches(reg2));
System.out.println("P@ssw0r\\".matches(reg2)); //not work
System.out.println("P@ssw0r$".matches(reg2));
System.out.println("P@ssw0r(".matches(reg2));
System.out.println("P@ssw0r)".matches(reg2));
System.out.println("P@ssw0r_".matches(reg2));
System.out.println("P@ssw0r+".matches(reg2));
System.out.println("P@ssw0r'".matches(reg2));
System.out.println("P@ssw0r;".matches(reg2));
System.out.println("P@ssw0r:".matches(reg2));
System.out.println("P@ssw0r?".matches(reg2));
System.out.println("P@ssw0r.".matches(reg2));
System.out.println("P@ssw0r.][".matches(reg2));
}
Please suggest my regular expression to work on the string with \
character, and guide me if my approach is wrong.