two or more whitespace regular expression?

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


Thus spake eugene kim (eugene1977 at hotmail.com):

> 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. 




Cheers,


Aldo






-- 
Aldo Cortesi
aldo at nullcube.com
http://www.nullcube.com




More information about the Python-list mailing list