RE question

Mike Fletcher mfletch at
Tue Apr 18 15:40:41 CEST 2000

Your regex matches any letter of [abc] at least once, stores that as the
group result, then goes back and tries again.  The last result the group
gets is c...

[abc] -> a
() -> store a
+ -> repeat group
[abc] -> b
() -> store b
+ -> repeat group
[abc] -> c
() -> store c
+ -> repeat group
[abc] -> stop
() -> stop
return, with c as result for group 1

Re's don't allow for storing multiple group match results for the same
group.  For that, get yourself a parsing system :) .

	([abc]+) -> abc
except MikeyMissingPoint:
	shake head in amazement at him


-----Original Message-----
From: Benyang Tang [mailto:btang at]
Sent: Monday, April 17, 2000 7:24 PM
To: python-list at
Subject: RE question

>>> m = re.match("([abc])+", "abc");

Why is it 'c', instead of 'a'?

More information about the Python-list mailing list