two or more whitespace regular expression?

Aldo Cortesi aldo at
Sun Sep 15 00:40:24 EDT 2002

Thus spake eugene kim (eugene1977 at

> i used this..
> words = string.split(line, '['+string.whitespace 
> +']'+'['string.whitespace+']+')

The string "split" method does not take regular expressions
- you need to use the re module for that. Try the following:

import re
line = "a b  c   d    e"
print re.split(r"\s+", line)

Read the re module documentation for more information on
regular expression syntax. 



Aldo Cortesi
aldo at

More information about the Python-list mailing list