regex question

proctor 12cc104 at gmail.com
Fri Apr 27 02:33:57 EDT 2007


hello,

i have a regex:  rx_test = re.compile('/x([^x])*x/')

which is part of this test program:

============

import re

rx_test = re.compile('/x([^x])*x/')

s = '/xabcx/'

if rx_test.findall(s):
	print rx_test.findall(s)

============

i expect the output to be ['abc'] however it gives me only the last
single character in the group: ['c']

C:\test>python retest.py
['c']

can anyone point out why this is occurring?  i can capture the entire
group by doing this:

rx_test = re.compile('/x([^x]+)*x/')
but why isn't the 'star' grabbing the whole group?  and why isn't each
letter 'a', 'b', and 'c' present, either individually, or as a group
(group is expected)?

any clarification is appreciated!

sincerely,
proctor




More information about the Python-list mailing list