Remove HTML tags (except anchor tag) from a string using regular expressions

Anand abpillai at gmail.com
Tue Feb 1 07:43:11 EST 2005


How about...

import re
content = re.sub('<([^!(a>)]([^(/a>)]|\n)*)>', '', content)
Seems to work for me.

HTH

-Anand




More information about the Python-list mailing list