import re
l='a1d22d'
#贪婪匹配在匹配元素间用 .*
tanlan=re.match('a.*d',l)
#非贪婪匹配在匹配元素间用 .*?
untanlan=re.match('a.*?d',l)
print("贪婪匹配结果是%s"%tanlan.group()+"\n非贪婪匹配结果是%s"%untanlan.group())
import re
l='a1d22d'
#贪婪匹配在匹配元素间用 .*
tanlan=re.match('a.*d',l)
#非贪婪匹配在匹配元素间用 .*?
untanlan=re.match('a.*?d',l)
print("贪婪匹配结果是%s"%tanlan.group()+"\n非贪婪匹配结果是%s"%untanlan.group())