Must be a bug in the re module [was: Why this result with the re module]

Yingjie Lan lanyjie at yahoo.com
Wed Nov 3 00:17:07 EDT 2010


--- On Wed, 11/3/10, John Bond <lists at asd-group.com> wrote:


> Just to clarify - findall is returning:
> 
> [ (only match in outer group, 1st match in inner group)
> , (only match in outer group, 2nd match in inner group)
> , (only match in outer group, 3rd match in inner group)
> , (only match in outer group, 4th match in inner group)
> , (only match in outer group, 5th match in inner group)
> , (only match in outer group, 6th match in inner group)
> ]
> 
> Where "only match in outer group" = "6th match in inner
> group" owing to the way that capturing groups with
> repetition only return the last thing they matched.
> 

---On Wed, 11/3/10, MRAB wrote-------

> Therefore the outer (first) group is always an empty string and the
> inner (second) group is the same as the previous example (the last
> capture or '' if no capture).

OK, I've got that, and I have no problem with the capturing part.
My real problem is with the number of total matches.
I think it should be 4 matches in total but findall 
gives 6 matches, for the new regex '((.a.)*)*'.
I'd love to know what you think about this.

Many thanks!
Yingjie



      



More information about the Python-list mailing list