a simple regex question

John Salerno johnjsal at NOSPAMgmail.com
Fri Mar 31 18:39:43 EST 2006


Ok, I'm stuck on another Python challenge question. Apparently what you 
have to do is search through a huge group of characters and find a 
single lowercase character that has exactly three uppercase characters 
on either side of it. Here's what I have so far:

pattern = '([a-z][A-Z]{3}[a-z][A-Z]{3}[a-z])+'
print re.search(pattern, mess).groups()

Not sure if 'groups' is necessary or not.

Anyway, this returns one matching string, but when I put this letter in 
as the solution to the problem, I get a message saying "yes, but there 
are more", so assuming this means that there is more than one character 
with three caps on either side, is my RE written correctly to find them 
all? I didn't have the parentheses or + sign at first, but I added them 
to find all the possible matches, but still only one comes up.

Thanks.



More information about the Python-list mailing list