-1

My CMS stores HTML double encoded, and I'd like to un-encode it with JavaScript. I've looked at Unescape HTML entities in Javascript? but solutions like this only address html that's been encoded once.

By double encoded, I mean that a character like < doesn't just become &lt;, it becomes &amp;lt;

Example:

&amp;lt;h1&amp;gt;Beginning November 1st, Renew your Membership online&amp;lt;/h1&amp;gt;&#xD; &amp;lt;a href=&amp;quot;/join-renew&amp;quot; class=&amp;quot;btn&amp;quot;&amp;gt;Join/Renew&amp;lt;/a&amp;gt;
noexit
  • 23
  • 1
  • 7

1 Answers1

0

It appears that it is just encoding the & so if you just do a Regular Expression that captures the ampersand encoding like so /amp;/g do a string.replace(regEx, "") should solve the problem then do a regular decode html entities. If you want to read more about Regular Expressions visit this link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions