I need to replace almost all HTML tags from string.
The content of tags should be kept.
There are just a few tags I would like to keep:
- p
- li
- ul
- ol
- b
e.g.:
INPUT:
"<p>TEXT</p><div>container</div><p></p><ul><li><b>list element</b>: 0.1 [mm]</li><li><strong>Another list element</strong>: 0.2</li></ul><span>span element</span>"
ā
OUTPUT:
"<p>TEXT</p>container<p></p><ul><li><b>list element</b>: 0.1 [mm]</li><li>Another list element: 0.2</li></ul>span element"
I know that i can do it by replacing all tags one by one:
string.replace(/<\/span>/g, '');
Maybe there is any faster option.
How can I achieve it?