search搜索到一次就返回结果
findall返回所有结果集合
match从开头匹配,如果开头不符合就返回None
strnote =u'只要 82元 ¥96 只要 23元 ¥275'
strnote1=u' 蓝牙音箱 39元包邮(需用券)'
strnote2=u'男款机械腕表 $549(需用码,约¥3630)'
strnote3 =u'玻璃水具5件套 ¥19.9'
strnote4 =u'¥32.7包邮'
ret = re.compile(ur'(\d{1,5})元 ¥(\d{1,5})').findall(strnote)
ret2 = re.search(ur'(\d{1,5})元 ¥(\d{1,5})',strnote)
ret3 = re.search(ur'(\d{1,5}[\.\d{1,3}]*)元',strnote3)
if notret3:ret3 = re.search(ur'¥(\d{1,5}[\.\d{1,3}]*)',strnote3)
ret4 = re.match(ur'¥(\d{1,5}[\.\d{1,3}]*)',strnote4)
if ret:printret
if ret2:printret2.groups()
if ret3:printret3.groups()
if ret4:printret4.groups()
=======
以上输出
[(u'82', u'96'), (u'23', u'275')]
(u'82', u'96')
(u'19.9',)
(u'32.7',)