Behavior of re.split on empty strings is unexpected

Peter Otten __peter__ at web.de
Mon Aug 2 20:01:21 CEST 2010


John Nagle wrote:

> The regular string split operation doesn't yield empty strings:
> 
> >>> "   HELLO   THERE ".split()
> ['HELLO', 'THERE']

Note that invocation without separator argument (or None as the separator) 
is special in that respect:

>>> " hello there ".split(" ")
['', 'hello', 'there', '']

Peter



More information about the Python-list mailing list