当前位置:编程学习 > JAVA >>

字符串中获取手机号码

private static String checkNum(String num){
  if(num == null || num.length() == 0){return "";}
  Pattern pattern = Pattern.compile("(?<!\\d)(?:(?:1[358]\\d{9})|(?:861[358]\\d{9}))(?!\\d)"); 
  Matcher matcher = pattern.matcher(num); 
      StringBuffer bf = new StringBuffer(64); 
      while (matcher.find()) { 
        bf.append(matcher.group()).append(","); 
      } 
      int len = bf.length(); 
      if (len > 0) { 
        bf.deleteCharAt(len - 1); 
      } 
      return bf.toString();
 } 

 

补充:软件开发 , Java ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,