re.compile().split(): why it produces empty string as a first element of the list
Lawrence D'Oliveiro
ldo at geek-central.gen.new_zealand
Wed Sep 27 05:36:26 EDT 2006
In message <lLidnaMLFaJMkofYnZ2dnUVZ_qednZ2d at comcast.com>, alf wrote:
> Fredrik Lundh wrote:
>> 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>
>>
> so is it safe to say that the index of separator in the list is always
> an odd number?
Hard to see why not.
More information about the Python-list
mailing list