0
点赞
收藏
分享

微信扫一扫

js replace正则

​​https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace​​


替换字符串中指定字符为超链接

使用$&获取匹配字符串

var aa = "SCM-sdfkjl"
var repstr = "<a href='" + this.GLOBAL.URL + "/browse/$&' target='_blank' style='color: blue'>$&</a>";
aa.replace(/\n/g, "<br>").replace(/(LDP-[0-9]+)|(SCM-[0-9]+)/g, repstr);


举报

相关推荐

0 条评论