regex question

proctor 12cc104 at
Fri Apr 27 08:33:57 CEST 2007


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']


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!


More information about the Python-list mailing list