一 从字符串中将手机号取出来(可以区分身份证号、银行卡号)
/**
* 从字符串中取出手机号(可以区分身份证号、银行卡号)
* @param sParam
* @return
*/
public String getTelnum(String sParam){
if(sParam.length()<=0)
return "";
String regex ="(?<!\\d)1[34578]\\d{9}(?!\\d)";// "[1]"代表第1位为数字1,"[3578]"代表第二位可以为3、5、8中的一个,"\\d{9}"代表后面是可以是0~9的数字,有9位。
Pattern pattern = Pattern.compile(regex);
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();
}