检测手机号码是否合法(正则表达式)
检测手机号码是否合法,可以加上这几行代码。
String reg = "^[1][358][0-9]{9}$"; Pattern pattern = Pattern.compile(reg); Matcher matcher = pattern.matcher(telephone); boolean b = matcher.matches();
b为true合法,false不合法
检测手机号码是否合法,可以加上这几行代码。
String reg = "^[1][358][0-9]{9}$"; Pattern pattern = Pattern.compile(reg); Matcher matcher = pattern.matcher(telephone); boolean b = matcher.matches();
b为true合法,false不合法