I am doing the Python challenge and while I figured out the answer to a puzzle, I did it in a hacky, not-very-good way. Upon advancing I was able to see the solution which is:
string1 = open('text.txt').read()
print ''.join(re.findall('[^A-Z][A-Z]{3}([a-z])[A-Z]{3}[^A-Z]', string1))
I messed with this for a while, removing a caret here and seeing what happens, changing a braced group there. However, I just cant wrap my head around why this works. Could anyone explain it in a easy to understand way?
Thank you!
I compiled the pattern as verbose to include inline comments:
Demo: