java正则--手机号格式验证
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class tes {
public static void main(String[] args) {
/* testPhone("15754332486");*/
System.out.println(testPhone("15754332486"));
}
public static boolean testPhone(String str) {
Pattern pat = Pattern.compile("^[1][3578][0-9]{9}$");
Matcher mat = pat.matcher(str);
return mat.find();
}
}
还没有评论,来说两句吧...