I’m trying to match hashtags in a string that also has html elements in it.
So I want to match # then go back to the first non-word character except when that non-word character is in a html element in which case keep going.
I started with #[\w]* for the basic case then tried to exclude tags with #[\w]*(?!([^<]+)?|>) but I’m getting no joy.
Example
First #Match1 tag then another #Mat<span class="tag"></span>ch2, #<span class="tag"></span>Match3.
Matches
#Match1
#Mat<span id="selectionBoundary"></span>ch2
#<span id="selectionBoundary"></span>Match3
Unfortunately I can’t strip the html elements and the match should contain the element.
Thanks
Looks like
#([\w]|(<[^>]+>))*will do the job