How to match a hard space

A export at hope.cz
Thu Oct 3 12:44:34 CEST 2002


Hi,
I need to replace in a string several spaces by one space only for example
from  text

"""      
(image)     Country    From
       Loading region"""


I need to get
 """(image) Country From Loading region"""

I use the following code

import re
text="""      (image)     Country    From
       Loading region"""

p = re.compile('\s+')
vy=p.sub(' ',text)
print vy

It works well only if there is a normal space( \x20 value) but if there is a hard space( 
\x20\xA0) it does not work.
Can you please help?
Thanks 
Ladislav






More information about the Python-list mailing list