[EMAIL PROTECTED] wrote: > Fairly new to this regex thing, so this might be very juvenile but > important. > > I cannot understand and why 'c' constitutes a group here without being > surrounded by "(" ,")" ? > >>>>import re >>>> m = re.match("([abc])+", "abc") >>>> m.groups() > ('c',) > > Grateful for any clarity. > The group matches a single letter a, b, or c. That group must match one or more times for the entire expression to match: in this case it matches 3 times once for the a, once for the b and once for the c. When a group matches more than once, only the last match is available, i.e. the 'c'. The matches against the a and b are discarded.
Its a bit like having some code: x = 'a' x = 'b' x = 'c' print x and asking why x isn't 'a' and 'b' as well as 'c'. -- http://mail.python.org/mailman/listinfo/python-list