Remove HTML tags in script
<p>I've found this piece of code on the internet. It takes a sentence and makes every single word into link with this word. But it has weak side: if a sentence has HTML in it, this script doesn't remove it.</p>

<p>For example: it replaces '<code>&lt;b&gt;asserted&lt;/b&gt;</code>' with '<code>http://www.merriam-webster.com/dictionary/&lt;b&gt;asserted&lt;/b&gt;</code>'</p>

<p>Could you please tell me what to change in this code for it to change '<code>&lt;b&gt;asserted&lt;/b&gt;</code>' to '<code>http://www.merriam-webster.com/dictionary/asserted</code>'.</p>

<pre><code>var content = document.getElementById("sentence").innerHTML;

var punctuationless = content.replace(/[.,\/#!$%\Ø^?&amp;\*;:{}=\-_`~()ââ"]/g, "");
var mixedCase = punctuationless.replace(/\s{2,}/g);
var finalString = mixedCase.toLowerCase();

var words = (finalString).split(" ");

var punctuatedWords = (content).split(" ");

var processed = "";
for (i = 0; i &lt; words.length; i++) {
    processed += "&lt;a href = \"http://www.merriam-webster.com/dictionary/" + words[i] + "\"&gt;";
    processed += punctuatedWords[i];
    processed += "&lt;/a&gt; ";
}

document.getElementById("sentence").innerHTML = processed;
</code></pre>

<p>This regex /&lt;{1}[^&lt;>]{1,}>{1}/g should replace any text in a string that is between two of these &lt;> and the brackets themselves with a white space. This</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>  var str = "&lt;hi&gt;How are you&lt;hi&gt;&lt;table&gt;&lt;tr&gt;I&lt;tr&gt;&lt;table&gt;love cake&lt;g&gt;"
  str = str.replace(/&lt;{1}[^&lt;&gt;]{1,}&gt;{1}/g," ")
  document.writeln(str);</code></pre>
</div>
</div>
</p>

<p>will give back " How are you I love cake".</p>

<p>If you paste this</p>

<pre><code>var stripHTML = str.mixedCase(/&lt;{1}[^&lt;&gt;]{1,}&gt;{1}/g,"")
</code></pre>

<p>just below this</p>

<pre><code>var mixedCase = punctuationless.replace(/\s{2,}/g);
</code></pre>

<p>and replace mixedCase with stripHTML in the line after, it will probably work</p>

javascript python regex replace