If i had a string:
hey <a href="#user">user</a>, what are you doing?
How, with regex could I say: look for user
, but not inside of <
or >
characters? So the match would grab the user between the <a></a>
but not the one inside of the href
I'd like this to work for any tag, so it wont matter what tags.
== Update ==
Why i can't use .text()
or innerText is because this is being used to highlight results much like the native cmd/ctrl+f functionality in browsers and I dont want to lose formatting. For example, if i search for strong
here:
Some <strong>strong</strong> text.
If i use .text()
itll return "Some strong text" and then I'll wrap strong
with a <span>
which has a class for styling, but now when I go back and try to insert this into the DOM it'll be missing the <strong>
tags.