// 从内容中提取手机号
public static List
String regex = “^((13[0-9])\|(14[5,7])\|(15[0-3,5-9])\|(17[0,3,5-8])\|(18[0-9])\|166\|198\|199\|(147))\\d{8}$“;
List
if(StringUtils.isBlank(content)){
}
Pattern pattern = Pattern.compile(“(?Matcher matcher = pattern.matcher(content);
StringBuffer bf = new StringBuffer(64);
while (matcher.find()) {
bf.append(matcher.group()).append(“,“);
}
int len = bf.length();
if (len > 0) {
bf.deleteCharAt(len - 1);
String phone = bf.toString();
String [] phoneSplit = phone.split(“,“);
for(String telephone : phoneSplit){
boolean isTruePhone = Pattern.matches(regex, telephone);
if(isTruePhone){
result.add(telephone);
System.out.println(telephone);
}
}
}
return result;
}
原文链接: https://onlyou.blog.csdn.net//article/details/83867593