Home

linnewbie@gmail.com 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'.

previous
next

valid use of cast
Re: Important Research Project
PYTHONPATH not working on Windows XP (?)
Re: Excel process still running after program completion - SOLVED
Re: How do I pass a memory pointer between DLLs?
Mariquita
części mitsubishi
www.bwin.com
RTV
blog kobiety