例子如下:
a =
'Peter d,, 13tsddgjlsv >>bgeghg
"desfegeivm,x,wb.rhwrohjow" dddeuvb
"dwegjosnngweibmbe,,benbie"
hello world
'
输出的结果如下(字符串):
‘Peter d,, 13tsddgjlsv >>bgeghg
dddeuvb
hello world’
import re
a ='Peter d,, 13tsddgjlsv >>bgeghg \n"desfegeivm,x,wb.rhwrohjow" dddeuvb \n"dwegjosnngweibmbe,,benbie" \nhello world '
print a
print '&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&\n'
match_list = re.findall(r'([^"]*)".*"([^"]*)', a) #返回一个数组,每个数组元素由一个元组构成
print 'match_list:', match_list, '\n'
print 'result: '
for x in match_list: #遍历match