public static void main(String[] args) {
String str = "bAa";
Pattern p = Pattern.compile("^[A-Za-z]+$");
Matcher m = p.matcher(str);
boolean isValid = m.matches();
System.out.println(isValid);
}
public static void main(String[] args) {
String str = "bAa";
Pattern p = Pattern.compile("^[A-Za-z]+$");
Matcher m = p.matcher(str);
boolean isValid = m.matches();
System.out.println(isValid);
}
楼上的太麻烦。
看这个
public static void main(String[] args) {
System.out.println("abgVBBG".matches("[a-zA-Z]+"));
}