a splitting headache

Paul Rubin http
Thu Oct 15 21:49:28 EDT 2009


Mensanator <mensanator at aol.com> writes:
> And the re module doesn't help.
> 
> >>> f = '  1 2  3   4    '
> >>> re.split(' ',f)
> ['', '', '1', '2', '', '3', '', '', '4', '', '', '', '']

filter(bool, re.split(' ', f))

You might also like:

    from itertools import groupby
    c = '0010000110'
    print list(list(xs) for k,xs in groupby(c))



More information about the Python-list mailing list