Background:
I found similiar S.O. posts on this topic, but I failed to make it work for my scenario. Appologies in advance if this is a dupe.
My Intent:
Take every English word in a string, and convert it to a html hyperlink. This logic needs to ignore only the following markup: <br/>
, <b>
, </b>
Here's what I have so far. It converts English words to hyperlinks as I expect, but has no ignore logic for html tags (that's where I need your help):
text = text.replace(/\b([A-Z\-a-z]+)\b/g, "<a href=\"?q=$1\">$1</a>");
Example Input / Output:
Sample Input:
this <b>is</b> a test
Expected Output:
<a href="?q=this">this</a> <b><a href="?q=is">is</a></b> <a href="?q=a">a</a> <a href="?q=test">test</a>
Thank you.