超链接识别

//识别并转换文本里的超链接
transSlink(value){
    let reg = /(http:\/\/|https:\/\/|www)((\w|=|\?|\.|\/|&|~|-|[\u200B-\u200D\uFEFF])+)/g;
    let text = value.replace(reg, "<a href='$1$2' target='_blank'>$1$2</a>").replace(/\n/g, "<br />");
    return text
},
posted @ 2022-02-18 16:59  huihuihero  阅读(162)  评论(0编辑  收藏  举报