Q:

regex findall only outputs first character of pattern

What I've been trying to do is make a pattern that looks like this: XXXxXXX where all x's are arbitrary letters but where the 1st and 4th of the big x's are the same. I also want to find all cases of this pattern in my string.
So this is he code i wrote (I made up the string just to test the pattern):
import re   

ring = "ABCaADEABCaADEABCaADEABCaADE"
regex = re.compile(r'([A-Z])[A-Z]{2}[a-z]\1[A-Z]{2}')

print regex.findall(ring)

And this is the output I got:
['A', 'A', 'A', 'A']

Then I tried to change the string so the 1st and 4th of the big letters don't match in the 4th repetition of the pattern in the string and this is what I got:
['A', 'A', 'A']

So it seems that the pattern is right, but for some reason it doesn't print out all of it?

A:

It's returning only first letter because only this part is in a group. You have to put whole regex in a group too. But after that first letter will be in second group, so you have to change \1 to \2.
Just try with:
(([A-Z])[A-Z]{2}[a-z]\2[A-Z]{2})

demo

