每天CookBook之Python-027

  • 短匹配的使用
import re

str_pat = re.compile(r'\"(.*?)\"')
text1 = 'Computer says "no."'

print(str_pat.findall(text1))

text2 = 'Computer says "no." Phone says "yes."'

print(str_pat.findall(text2))


``` bash
['no.']
['no.', 'yes.']
posted @ 2016-07-13 21:34  4Thing  阅读(108)  评论(0)    收藏  举报