输入内容验证

/**
* 验证验证输入字母
* 
* @param 待验证的字符串
* @return 如果是符合格式的字符串,返回 <b>true </b>,否则为 <b>false </b>
*/
public static boolean IsLetter(String str) {
String regex = "^[A-Za-z]+$";
return match(regex, str);
}

/**
* 验证验证输入汉字
* 
* @param 待验证的字符串
* @return 如果是符合格式的字符串,返回 <b>true </b>,否则为 <b>false </b>
*/
public static boolean IsChinese(String str) {
String regex = "^[u4e00-u9fa5],{0,}$";
return match(regex, str);
}

/**
* 验证验证输入字符串
* 
* @param 待验证的字符串
* @return 如果是符合格式的字符串,返回 <b>true </b>,否则为 <b>false </b>
*/
public static boolean IsLength(String str) {
String regex = "^.{8,}$";
return match(regex, str);
}
原文地址:https://www.cnblogs.com/20gg-com/p/6037528.html