标签:正则 url bsp cti 链接地址 https func amp http
最近项目中有用到判断URL文本转化为链接地址的正则,刚好记录下
/*替换链接*/
replaceSrc:function(txt){
var reg = /(((https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)/ig;
var result = txt.replace(reg,function(item){
return "<a href=‘"+item+"‘ target=‘_blank‘>"+item+"</a>";
});
return result;
}
标签:正则 url bsp cti 链接地址 https func amp http
原文地址:http://www.cnblogs.com/lr-blog/p/6871903.html