Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Strip html tags (See related posts)

import re
text = re.replace('<.*?>', '', html)

Comments on this post

AmbroseChapel posts on Mar 23, 2006 at 01:50
There are all kinds of terrible things which can go wrong with that method. There's no reason to trust that ">" characters don't appear inside ALT attributes of images, for instance. Does this also assume that the tags are all on the same line?

You need to create an account or log in to post comments to this site.


Click here to browse all 4861 code snippets

Related Posts