标签:ima new console aik bsp 图片 ons target blank
var str = ‘<a href="https://baike.baidu.com/item/%E7%B4%A2%E7%A6%8F%E5%85%8B%E5%8B%92%E6%96%AF" target="_blank"><u><font color="#0066cc">索福克勒斯</font></u></a><a href="https://baike.baidu.com/item/%E6%88%8F%E5%89%A7%E6%83%85%E6%99%AF" target="_blank"><u><font color="#0066cc">戏剧情景</font></u></a><a href="https://baike.baidu.com/item/%E6%9D%A8%E9%97%A8%E5%A5%B3%E5%B0%86" target="_blank"><u><font color="#0066cc">杨门女将</font></u></a>‘
var regs1 = new RegExp(/href="(.*?)"/,‘gi‘);
str = str.replace(regs1, "onclick=\"go(‘$1‘)\"");
console.log(str);
<a onclick="go(‘https://baike.baidu.com/item/%E7%B4%A2%E7%A6%8F%E5%85%8B%E5%8B%92%E6%96%AF‘)" target="_blank"><u><font color="#0066cc">索福克勒斯</font></u></a><a onclick="go(‘https://baike.baidu.com/item/%E6%88%8F%E5%89%A7%E6%83%85%E6%99%AF‘)" target="_blank"><u><font color="#0066cc">戏剧情景</font></u></a><a onclick="go(‘https://baike.baidu.com/item/%E6%9D%A8%E9%97%A8%E5%A5%B3%E5%B0%86‘)" target="_blank"><u><font color="#0066cc">杨门女将</font></u></a>
标签:ima new console aik bsp 图片 ons target blank
原文地址:https://www.cnblogs.com/fyhlz/p/11698463.html