#!/usr/bin/python2.6
# -*- coding: utf-8 -*-
import sys
import os
import string
import urllib2
import re
__author__ = "kaoyu"
__date__ = "$2010-4-6 13:25:33$"
def getWallpaper(x, y, start, pages):
"""To get wallpapers from interfaceLift.com"""
urllib2.URLError: <urlopen error (10060, 'Operation timed out')>
在CU上看到一贴,备忘
问:
s='aaa111aaa,bbb222,333ccc,444ddd444,555eee666,fff777ggg'
用正则表达式取出 前后字母相同的数据 结果如下:
111, ddd,
谢谢~
答:
result = [re.findall(r'^(.+)(.+?)(\1)$',i)[0][1] for i in s.split(',') if re.match(r'^(.+)(.+?)(\1)$',i)]
print result
print result
原帖地址
http://bbs3.chinaunix.net/thread-1603771-1-1.html