Re: the buggy regex in Python

2010-11-25 Thread Yingjie Lan
--- On Thu, 11/25/10, MRAB wrote: > > > Look at the spans: > > >>> for m in re.finditer('((.d.)*)*', 'adb'): >     print(m.span()) > >     > (0, 3) > (3, 3) > > There's an non-empty match followed by an empty match. If you read my first post, it should be apparent that that the empty string

Re: the buggy regex in Python

2010-11-25 Thread MRAB
On 25/11/2010 16:44, Yingjie Lan wrote: --- On Thu, 11/25/10, MRAB wrote: re.findall performs multiple searches, each starting where the previous one finished. The first match started at the start of the string and finished at its end. The second match started at that point (the end of the stri

Re: the buggy regex in Python

2010-11-25 Thread Yingjie Lan
--- On Thu, 11/25/10, MRAB wrote: > re.findall performs multiple searches, each starting where > the previous > one finished. The first match started at the start of the > string and > finished at its end. The second match started at that point > (the end of > the string) and found another match,

Re: the buggy regex in Python

2010-11-25 Thread MRAB
On 25/11/2010 11:32, Yingjie Lan wrote: I know many experts will say I don't have understanding...but let me pay this up front as my tuition. Here are some puzzling results I have got (I am using Python 3, I suppose similar results for python 2). When I do the following, I got an exception:

the buggy regex in Python

2010-11-25 Thread Yingjie Lan
I know many experts will say I don't have understanding...but let me pay this up front as my tuition. Here are some puzzling results I have got (I am using Python 3, I suppose similar results for python 2). When I do the following, I got an exception: >>> re.findall('(d*)*', 'adb') >>> re.finda