re.compile().split(): why it produces empty string as a first element of the list

Fredrik Lundh fredrik at pythonware.com
Wed Sep 27 01:34:30 EDT 2006


alf wrote:

> Let's run following:
> 
>  >>> re.compile('(\[.*?\])').split('[aa]bb[11]22')
> ['', '[aa]', 'bb', '[11]', '22']
> 
> Why does it return '' as a first element of the list?

because the string starts with a separator.

</F>




More information about the Python-list mailing list