[Tutor] Python Challenge - Riddle 2
Roel Schroeven
rschroev_nospam_ml at fastmail.fm
Tue May 10 09:51:18 CEST 2005
Liam Clarke wrote:
> This matches '[A-Z]{3}[a-z]{1}[A-Z]{3}' 477 occurences... so I hope
> that it's all the same letter.
You have to many occurences because that regex matches XXXxXXX, but also
XXXXXXxXXXXXX. You should only match exactly 3 guards on each side. IIRC
I used something like (sadly I threw my code for levels 1 and 2 away):
'[^A-Z][A-Z]{3}[a-z]{1}[A-Z]{3}[^A-Z]'
--
If I have been able to see further, it was only because I stood
on the shoulders of giants. -- Isaac Newton
Roel Schroeven
More information about the Tutor
mailing list