I would like to collapse whitespace in a string of the followinf foramat using a some pre defined functionalities.
XXXXX<space>-<space>XXXX shoud be converted to XXXXX-XXXXX
XXXXX<space>-XXXXX shoud be converted to XXXXX-XXXXX
Please help
I would like to collapse whitespace in a string of the followinf foramat using a some pre defined functionalities.
XXXXX<space>-<space>XXXX shoud be converted to XXXXX-XXXXX
XXXXX<space>-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.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.