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

Gabriel Cooper gabriel.cooper at mediapulse.com
Wed Feb 2 13:43:52 EST 2005


Max M wrote:

> If it's not to learn, and you simply want it to work, try out this 
> library:
>
> http://zope.org/Members/chrisw/StripOGram/readme
>
>
 >>> stripogram.html2safehtml('''first > last''',valid_tags=('i','a','br'))
'first > last'
 >>> stripogram.html2safehtml('''first < last''',valid_tags=('i','a','br'))
'first first '


keeping in mind that bare ">" and "<" are invalid HTML (should be > 
and <), why'd it leave the greater than and why are there two "first"'s ?



More information about the Python-list mailing list