数字匹配原则
public static boolean isNumeric(String num){
Pattern pattern = Pattern.compile("[0-9]*");
Matcher isNum = pattern.matcher(num);
if (!isNum.matches()) {
return false;
}
return true;
}
英文匹配原则
public static boolean isEnglish(String charaString){
return charaString.matches("^[a-zA-Z]*");
}
中文匹配原则
public static boolean isChinese(String str){
String regEx = "[\\u4e00-\\u9fa5]+";
Pattern p = Pattern.compile(regEx);
Matcher m = p.matcher(str);
if(m.find())
return true;
else
return false;
}
网友评论