字符串包含url匹配并替换成a标签超链接

正则匹配

function replaceURLWithHTMLLinks(text) {
    var exp = /((https?|ftp|file)://[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|])/i;
    return text.replace(exp,"<a href='$1'>$1</a>"); 
}
原文地址:https://www.cnblogs.com/lw5116/p/10872090.html