import re
'''
re模塊
compile
match search findall
group groups
正則表達式經常使用格式:
字符:\d \w \t .
(\d:數字;\w:字母數字下劃線_;\t:製表符;點.:處了回車外的全部字符)
次數:* + ? {m} {m,n}
(+:>=1數字;*:>=0個字符;?:0或1,{m}次,{m,n}範圍,包括n)
match字符串開頭開始匹配,第一個不匹配就返回none
search一次尋找整個整個字符串,直到匹配爲止,只返回一個匹配值
findall尋找字符串的全部,遍歷整個字符串,返回全部相匹配的值
'''
#match
res1 = re.match('\d+', 'wqe221111wd3345')
if res1:
print res1.group()
else:
print 'nothing'
#search
res2 = re.search('\d+','wqe221111wd3345')
if res2:
print res2.group()
else:
print 'nothing'
#findall
res3 = re.findall('\d+','wqe221111wd3345')
print res3
#compile
com = re.compile('\d+',)
print com.findall('wqe221111wd3345')
#group groups
res4 = re.search('(\d+)\w*(\d+)','wqe221111wd3345')
print res4.group()
print res4.groups()正則表達式