将字符串与regex外部图像和href标记与javascript匹配

将字符串与regex外部图像和href标记与javascript匹配,javascript,regex,Javascript,Regex,我正在尝试在和标记之外用正则表达式匹配单词 我有下面的代码,它只匹配所有标记之外的字符串 /test(?!.*<\/)/g /test(?。*这应该可以完成以下工作: var string = "hello<a asdf>hello</a>hello"; var regex = /(.*?)<a.*?>.*?<\/a>(.*?)/g; console.log(regex.exec(string)); var string=“hello

我正在尝试在
标记之外用正则表达式匹配单词 我有下面的代码,它只匹配所有标记之外的字符串

/test(?!.*<\/)/g

/test(?。*这应该可以完成以下工作:

var string = "hello<a asdf>hello</a>hello";

var regex = /(.*?)<a.*?>.*?<\/a>(.*?)/g;

console.log(regex.exec(string));
var string=“hellohello”;
var regex=/(.*).*(.*)/g;
log(regex.exec(字符串));

对于regex,这可能不是100%可能的。此位的求解是(不在>之间),并且不要将DOM视为可以跨regexp的大字符串。我需要在example@waterschaats更好地解释你自己
var string = "hello<a asdf>hello</a>hello";

var regex = /(.*?)<a.*?>.*?<\/a>(.*?)/g;

console.log(regex.exec(string));