#!-*- coding:UTF-8 -*-
'''
Created on 2015-4-12
@author: huangpeng03
'''
import re
str = 'abcabc'
m = re.search('a.*c',str) #最长匹配
if m:
print m.group()
n = re.search('a.*?c',str) #最短匹配
if n:
print n.group()
</pre><pre name="code" class="python">console:
abcabc
abc
还一些其他用法:
<img src="https://img-blog.csdn.net/20150412172728862?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvUVEzMzE5NDg3ODE=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />