Regex - where do I make a mistake?

Johny python at hope.cz
Fri Feb 16 07:44:32 EST 2007


I have
string="""<span class="test456">55</span>.
<td><span class="test123">128</span>
<span class="test789">170</span>
"""

where I need to replace
<span class="test456">55</span>.
<span class="test789">170</span>

by space.
So I tried

#############
import re
string="""<td><span class="test456">55</span>.<span
class="test123">128</span><span class="test789">170</span>
"""
Newstring=re.sub(r'<span class="test(?!123)">.*</span>'," ",string)
###########

But it does NOT work.
Can anyone explain why?
Thank you
L.




More information about the Python-list mailing list