Thursday, 5 September 2013

Python: Find and print previous element

Python: Find and print previous element

I have the following text (just an example): </i>5 <i></i><span class
I'd like to remove this space, so I tried: re.sub(r'</i>.* <i></i><span
class', '</i>%02d<i></i><span class' %, text)
But this did not work. How can I catch the "thing" which is found in ".*"?
%02d is obviously incorrect...
Thanks for the help :)

No comments:

Post a Comment