On 3/11/2010 4:23 AM, Yingjie Lan wrote:
--- On Wed, 11/3/10, MRAB<pyt...@mrabarnett.plus.com> wrote:
From: MRAB<pyt...@mrabarnett.plus.com>
Subject: Re: Must be a bug in the re module [was: Why this result with the re
module]
To: python-list@python.org
Date: Wednesday, November 3, 2010, 8:02 AM
On 03/11/2010 03:42, Yingjie Lan
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).
Now I am confused also:
If the outer group \1 is empty, how could the inner
group \2 actually have something?
Yingjie
I just explained that (I think!)! The outer capturing group uses
repetition, so it returns the last thing that was matched by the inner
group, which was an empty string. I
If you took away the outer groups repetition:
re.findall('((.a.)*)', 'Mary has a lamb')
then, for each of the six matches, it returns the full thing that was
matched:
('Mar', 'Mar'), ('', ''), ('', ''), ('has a lam', 'lam'), ('', ''), ('',
'')]
Cheers, JB
--
http://mail.python.org/mailman/listinfo/python-list