Stripping whitespace

Paul Rubin http
Wed Jan 23 20:05:01 CET 2008

ryan k <ryan at> writes:
> Hello. I have a string like 'LNAME
> PASTA               ZONE'. I want to create a list of those words and
> basically replace all the whitespace between them with one space so i
> could just do lala.split(). Thank you!

import re
s = 'LNAME  PASTA        ZONE'
re.split('\s+', s)

More information about the Python-list mailing list