---
title: "python challenge 3"
author: "he_lux"
date: "2009-12-28T17:54:11Z"
tags: []
categories: ["编程语言"]
slug: "python-challenge-3"
draft: false
lastmod: "2009-12-28T17:54:11Z"
id: 558484
url: "https://hhlux.iteye.com/blog/558484"
---

第三题比较简单，One small letter, surrounded by EXACTLY three big bodyguards on each of its sides. 即一个小写字母，两边各有不多不少的三个大写字母。 用正则表达式搞定。

```python

import re

if __name__ == '__main__':
    # put the mess from the page source into 3.txt 
    f = open('3.txt', 'r')
    text = f.read()
    
    list = re.findall('[^a-z][a-z]{3}[a-z][a-z]{3}[^a-z]', text)
    
    print(''.join(x[4:5] for x in list))
    
    f.close();

```