Python - replace HTML-looking tags in text

Viewed 34

I'm trying to change all HTML-looking tags in an input string if they are not valid HTML tags. By HTML-looking tags I mean a substring that is within <> brackets. For example, I would like to change

<p><em>This is an <example></em>. <strong>This is another</strong> <one>. <a href="[LINK]">test</a></p>

to

<p><em>This is an &lt;example&gt;</em>. <strong>This is another</strong> &lt;one&gt;. <a href="[LINK]">test</a></p>

I'm doing this in Python. Thanks for your help!

0 Answers
Related