| | |
| | | * |
| | | */ |
| | | 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; |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * 判断字符串是不是double型 |
| | | * @param str |
| | | * @return |
| | | */ |
| | | public static boolean isNumeric(String str){ |
| | | Pattern pattern = Pattern.compile("[0-9]+[.]{0,1}[0-9]*[dD]{0,1}"); |
| | | Matcher isNum = pattern.matcher(str); |
| | | if( !isNum.matches() ){ |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * @param regex |
| | | * 正则表达式字符串 |
| | | * @param str |