Stripping whitespace

Paul Rubin http
Wed Jan 23 14:05:01 EST 2008


ryan k <ryan at ryankaskel.com> 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