//匹配手机号 public static boolean isTelephone(String tele){ if (tele.isEmpty()) { return false; } if (tele.matches("^0?1[0-9]{10}$")) { return true; } return false; } //匹配数字 public static boolean isNumber(String num){ if (num.isEmpty()) { return false; } if (num.matches("^[1-9]\\d+$")) { return true; } return false; } //匹配电子邮箱 public static boolean isEmail(String email){ if (email.isEmpty()) { return false; } if (email.matches("^[\\w!#$%&'*+/=?^_`{|}~-]+(?:\\.[\\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\\w](?:[\\w-]*[\\w])?\\.)+[\\w](?:[\\w-]*[\\w])?$")) { return true; } return false; }
java中正则匹配
猜你喜欢
转载自sky-xin.iteye.com/blog/2251659
今日推荐
周排行