java通过正则表达式提取字符串中的手机号,简单快速方便,能提取多个手机号
public String getTelnum(String sParam){
if(sParam.length()<=0)
return "";
Pattern pattern = Pattern.compile("(1|861)(3|5|8)\\d{9}$*");
Matcher matcher = pattern.matcher(sParam);
StringBuffer bf = new StringBuffer();
while (matcher.find()) {
bf.append(matcher.group()).append(",");
}
int len = bf.length();
if (len > 0) {
bf.deleteCharAt(len - 1);
}
return bf.toString();
}
Java提取字符串中的手机号,码迷,mamicode.com
时间: 2024-12-25 17:16:53