我试着在<a></a>和<img />标签外使用正则表达式匹配单词,我有一个只匹配所有标签外的字符串的代码
/test(?!.*<\/)/gA标记之间的测试字符串不应与后两个sould匹配
<a>test</a> test lorem test有什么想法吗?
发布于 2016-07-06 01:22:41
这应该可以完成以下工作:
var string = "hello<a asdf>hello</a>hello";
var regex = /(.*?)<a.*?>.*?<\/a>(.*?)/g;
console.log(regex.exec(string));https://stackoverflow.com/questions/38208989
复制相似问题