不多说,贴代码,一看就会.
/** * @param mobiles * @return [0-9]{5,9} */ public static boolean isMobileNO(String mobiles) { if (mobiles.length() != 11) { return false; } boolean flag = false; try { Pattern p = Pattern .compile("^((13[0-9])|(15[^4,\\D])|(18[0,1-9]))\\d{8}$"); Matcher m = p.matcher(mobiles); flag = m.matches(); } catch (Exception e) { flag = false; } return flag; } /** * @param name * @return 中文 名字必须是中文 */ public static boolean isName(String name) { if (name.length() == 0) { return false; } boolean flag = false; try { Pattern p = Pattern.compile("^[\\u4E00-\\u9FA5\\uF900-\\uFA2D]+$"); Matcher m = p.matcher(name); flag = m.matches(); } catch (Exception e) { flag = false; } return flag; }