Tuesday, 10 September 2013

Python: Replacing strings

Python: Replacing strings

I'm iterating through pages and I'd like to modify lines containing
<span class="font16"></span>
How can I correct the code below?
text = re.sub(r'<span class="font(.*)"></span><span', r'<span
class="font\1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </span><span', text)

No comments:

Post a Comment