判断是否有11位数字,如果有,给数字添加链接

<p>12345678901sw</p>

var circleList;
var isPhone = /d{11}/g;
circleList = $("p").html();
var arrPhone = circleList.match(isPhone);
console.log(arrPhone);
circleList = circleList.replace(isPhone, function(word) {
return '<a href="tel:' + word + '">' + word + '</a>';
})
$("p").html(circleList);

原文地址:https://www.cnblogs.com/yixiancheng/p/5942807.html