I tried the code below in Java but I think its wrong:
import java.util.regex.Pattern;
public class Main {
public static void main(String[] args) {
System.out.println(Pattern.matches("[A-z]+", "1d"));
System.out.println(Pattern.matches("[0-9]+", "1d"));
System.out.println(Pattern.matches("[A-z]+", "1"));
System.out.println(Pattern.matches("[0-9]+", "d"));
}
}
And I expected this output:
true
true
false
false
but I got this output:
false
false
false
false
Why is the output of Java wrong?