| | |
| | | * |
| | | */ |
| | | public class RegValidatorUtil { |
| | | |
| | | |
| | | /**手机号正则初始化*/ |
| | | public static Pattern pattern = Pattern.compile("^1[3-9]\\d{9}$"); |
| | | |
| | | /** |
| | | * 验证邮箱 |
| | | * |
| | |
| | | return match(regex, str); |
| | | } |
| | | |
| | | /** |
| | | * 验证输入手机号码 |
| | | * |
| | | * @param str 待验证的字符�? |
| | | * @return 如果是符合格式的字符�?,返回 <b>true </b>,否则�? <b>false </b> |
| | | */ |
| | | public static boolean IsHandset(String str) { |
| | | String regex = "^[1]+[3,5]+\\d{9}$"; |
| | | return match(regex, str); |
| | | /**校验手机号码 |
| | | * @param phoneNumber 手机号 |
| | | * @return 校验结果 |
| | | */ |
| | | public static boolean IsHandset(String phoneNumber) { |
| | | if ((phoneNumber != null) && (!phoneNumber.isEmpty())) { |
| | | Matcher m = pattern.matcher(phoneNumber); |
| | | return m.matches(); |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |