Python Challenge level 3: “re”

Level 3 is the last of these initial text processing problems. Everything quite easy for now.

Hint 1: One small letter, surrounded by EXACTLY three big bodyguards on each of its sides.

#!/usr/bin/env python
import re
mess = open("03.txt").read()
print ''.join(re.findall('[^A-Z][A-Z]{3}([a-z])[A-Z]{3}[^A-Z]',
 mess))

linkedlist

From linkedlist.html we’re sent to linkedlist.php, and up to Level 4.

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

5 Comments »

 
  • Nicolai Negru says:

    Used the same expression, but was trying to apply just ONE SMALL LETTER… instead of joining all of them.

    Thanks a lot :)

  • The game just keeps getting better. I’ve been really busy lately and the game was left parked for now, but I’m really looking forward to finish the remaining levels. The game is worth it :)
    BTW, happy 2008!

  • yhvh says:

    bah… I’d left out the [^A-Z] at the start and end,

  • JK says:

    As of today, `[^A-Z]` at the beginning and end of the regex is necessary to get the result instead of way more characters.

    Also, the result is rot13-encoded (the challenge description doesn’t seem to say anything about using a substitution cipher, but it had to be used in an earlier challenge).

  • DirtyToenail says:

    can someone explain why ‘[^A-Z][A-Z]{3}’ doesn’t try to match the first character of the string in the character class [A-Z] then 3 more occurrences of [A-Z] for a total of 4 matched characters?

 

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>