您的当前位置: 首页>帮助中心>纸浆周

博云建站

新闻公告
关于我们

javascript 查找字符串中的手机号,并替换内容


阅读:54


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');

            

    }


上一篇:tomcat9 安装APR 开启apr 下一篇:centos 系统数据盘扩容代码

 
 
185-3146-6707