Behavior of re.split on empty strings is unexpected

jhermann Juergen.Hermann at 1und1.de
Thu Aug 5 06:07:55 EDT 2010


On Aug 2, 7:34 pm, John Nagle <na... at animats.com> wrote:
>  >>> s2 = "   HELLO   THERE  "
>  >>> kresplit4 = re.compile(r'\W+', re.UNICODE)
>  >>> kresplit4.split(s2)
> ['', 'HELLO', 'THERE', '']
>
> I still get empty strings.

>>> re.findall(r"\w+", " a b c ")
['a', 'b', 'c']




More information about the Python-list mailing list