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

2006-09-27 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, 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 s

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

2006-09-26 Thread alf
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. > > > so is it safe to say tha

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

2006-09-26 Thread Fredrik Lundh
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. -- http://mail.python.org/mailman/listinfo/python-list

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

2006-09-26 Thread alf
Hi, 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? Any insight? -- alf -- http://mail.python.org/mailman/listinfo/python-list