pythonchallenge 【第3题】

 新博客地址:http://gorthon.sinaapp.com/

http://www.pythonchallenge.com/pc/def/equality.html

这个题目的意思一直没有明白……

其实是这样的,如rRSHpSDBi这样中间的那个p就是要找的字母。

import urllib2,re f=urllib2.urlopen('http://www.pythonchallenge.com/pc/def/equality.html') str= f.read() res=re.findall(r"(?<=[^A-Z][A-Z]{3})[a-z](?=[A-Z]{3}[^A-Z])", str) #或 #res=re.findall(r"[^A-Z][A-Z]{3}([a-z])[A-Z]{3}[^A-Z]", str) print ''.join(res) >>> linkedlist >>> 

###################################################

C++版本:

#include <string.h> #include "deelx.h"//正则表达式库 #include <stdio.h> int main(void) { char *a="kAewtloYgcFQaJNhHVG………………"; static CRegexpT <char> regexp("[^A-Z][A-Z]{3}[a-z][A-Z]{3}[^A-Z]"); MatchResult result = regexp.Match(a); while( result.IsMatched() ) { printf("%.*s", result.GetEnd() - result.GetStart()-8, a + result.GetStart() + 4); result = regexp.Match(a, result.GetEnd()); } return 0; } 

结果:

linkedlist

Process returned 0 (0x0)   execution time : 0.328 s

Press any key to continue.

 

你可能感兴趣的:(pythonchallenge 【第3题】)