java正则--手机号格式验证

超、凢脫俗 2022-01-28 17:41 518阅读 0赞
  1. import java.util.regex.Matcher;
  2. import java.util.regex.Pattern;
  3. public class tes {
  4. public static void main(String[] args) {
  5. /* testPhone("15754332486");*/
  6. System.out.println(testPhone("15754332486"));
  7. }
  8. public static boolean testPhone(String str) {
  9. Pattern pat = Pattern.compile("^[1][3578][0-9]{9}$");
  10. Matcher mat = pat.matcher(str);
  11. return mat.find();
  12. }
  13. }

发表评论

表情:
评论列表 (有 0 条评论,518人围观)

还没有评论,来说两句吧...

相关阅读