用正则表达式去除href后面的字符串
可以使用以下正则表达式去除href后面的字符串:
/href=".+?"/g
在JavaScript中可以使用replace()函数来替换匹配到的字符串,将其替换为空字符串即可。以下是一个示例代码:
var str = '<a href="http://www.example.com">Example</a>';
var result = str.replace(/href=".+?"/g, 'href=""');
console.log(result); // 输出: '<a href="">Example</a>'
原文地址: https://www.cveoy.top/t/topic/ikVL 著作权归作者所有。请勿转载和采集!