阅读:10
javascript 查找字符串中的手机号,并替换内容
通用方法
function replacePhone2(content,title){
var est=/\d{11}/g;
var string2=content.match(est);
var shouji="";
if(string2!=null){
shouji=string2[0]
}
content=content.replace(shouji,'<a href="tel:'+shouji+'" style=" color: #23bd12;">'+shouji+'</a>');
var list = title.split(" ");
for(var i=0;i<list.length;i++){
if(list[i]!=""){
content=content.replace(list[i],'<a href="javascript:;" style=" color: red">'+list[i]+'</a>');
}
}
return content.replace(/br/ig,'/span');
}