'Escape custom tags except html tags

I want to escape custom tags except for HTML tags such as strong, bold, italic.

 Input: "Hello World! <notification>Name</notification><nat>Nat tag</nat> <strong>This should be strong</strong><nas>Nas Tag</nas>"

Output: Hello World! <notification>Name</notification> <nat>Nat tag</nat>**This should be strong**<nas> Nas Tag</nas>

string.replace(/</g, "<").replace(/>/g, ">") .replace(/"/g, """).replace(/'/g, "'")
.replace(/<(?!/?strong>)[^>]+>/g, '')

I tried with the above replace but it is also replacing <strong> with &lt; strong &gt; any help would be appreciated.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source