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

2005-02-02 Thread Gabriel Cooper
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'))

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

2005-02-01 Thread Nico Grubert
Hello, I want to remove all html tags from a string content except a ...xxx/a. My script reads like this: ### import re content = re.sub('([^!]([^]|\n)*)', '', content) ### It works fine. It removes all html tags from content. Unfortunately, this also removes a ...xxx/a occurancies. Any idea,

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

2005-02-01 Thread Anand
How about... import re content = re.sub('([^!(a)]([^(/a)]|\n)*)', '', content) Seems to work for me. HTH -Anand -- http://mail.python.org/mailman/listinfo/python-list

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

2005-02-01 Thread Anand
I meant content = re.sub ('[^!(a)]([^]|\n)*[^!(/a)]', '', content) Sorry for the mistake. However this seems to also print tags like b, p etc also. -Anand -- http://mail.python.org/mailman/listinfo/python-list

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

2005-02-01 Thread Max M
Nico Grubert 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 -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list