I would like to collapse whitespace in a string of the followinf foramat using a some pre defined functionalities.
XXXXX-XXXX shoud be converted to XXXXX-XXXXX XXXXX-XXXXX shoud be converted to XXXXX-XXXXX
Please help
-
Something like this should do:
s = 'xxxxx - xxxxx' space = ' ' nospace = '' s = s.replace(space, nospace) print s # xxxxx-xxxxx
>>> s = 'XXXXX -\n\t XXXX' >>> ''.join(s.split()) 'XXXXX-XXXX' >>>
Thanks a lot. Its working now.