I have a string of "abc123(" and want to check if contains one or more chars that are not a number or character.
"abc123(".matches("[^a-zA-Z0-9]+"); should return true in this case? But it dose not! Whats wrong?
My test script:
public class NewClass {
public static void main(String[] args) {
if ("abc123(".matches("[^a-zA-Z0-9]+")) {
System.out.println("true");
}
}
}
matches(yourRegex)in Java really meansmatches("^" + yourRegex + "$")