// 判断字符串是否同时有字母和数字,且不指定以字母或数字开头
public static boolean isLetterAndDigital(String content) {
String regEx ="([A-Za-z][0-9]+)|([0-9]+[A-Za-z]+)";
return Pattern.matches(regEx, content);
}
// 执行
public static void main(String[] args) {
String content ="f4";
System.out.println(isLetterAndDigital(content));
}
网友评论