例子:
srcstr = "abcda";
print re.findall(u'a',srcstr);//找出所有的匹配结果
匹配结尾:
如以wo结尾的
pa = re.compile(ur"wo$");
if pa.search("niaiwo"):
print "OK";
else:
print "not find";
注意,如果使用re.match,则是从字符串的头开始匹配。search是找出一个符合正则的字串,findall是找出所有的,而re.match则是看当前额整串是否符合正则。
所以上面的正则正确的写法应该是:re.compile(ur"\w+wo$"); \w+表示一个或者多个字符等