字符串中获取手机号码

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();
 }

posted @ 2013-06-29 22:15  爱生活,爱编程  阅读(1109)  评论(0编辑  收藏  举报