function link() {
let str = jsContainer.innerText;
//let str = 'test http://www.testhaha.com test test ';
const w = '[a-zA-Z0-9]+'
const reg = new RegExp(`((https://)|(http://))*w{3}\\.${w}(\\.(com|cn))+(\\?${w}=\\w*(#\\w*)*)*`,'g');
const res = str.match(reg);
if(!!res) {
let attr = '';
res.forEach( s => {
str = str.replace(s,function(str) {
attr = s.indexOf('www')== 0 ? 'http://' + s : s;
return `<a href=${attr} target="_blank">${str.trim()}</a>`;
})
})
jsContainer.innerHTML = str;
}
}
link();



京公网安备 11010502036488号