I am looking to build a regular expression that will select a single word out of all text between HTML tags. I am looking for the occurrence of the word anywhere but inside HTML tags. The issue is that the word I am looking to match may occur in the class or id of a tag - I would only like to match it when it is between the tags.
Here is further clarification from my comment: I am looking for a regex to use in a loop that will find a string in another string that contains HTML. The large string will contain something like this:
<div class="a-class"<span class="some-class" data-content="some words containing target">some other text containing target</span>
I want the regex to match the word "target" only between the tags, not within the tag in the data-content attribute. I can use:
/(\btarget)\b/ig
to find every instance of target.