two or more whitespace regular expression?
aleax at aleax.it
Sun Sep 15 03:33:50 EDT 2002
eugene kim wrote:
> i used this..
> words = string.split(line, '['+string.whitespace
> which didn't work..
The split method of a string (and the old split
function in module string, which internally just
invokes the split method) takes a string, not a
regular expression. To use regular expressions,
you must import re first. Then, for example:
twoormorewhites = re.compile(r'\s\s+')
words = twoormorewhites.split(line)
More information about the Python-list