Python re常用方法

import  re
s='hello world'
a=re.match('h.*',s)
print a.group()
a=re.search('e.*',s)
print(a.group())
a=re.findall('l.',s)
print a
a=re.split("l",s)
print a
a=re.sub('l.','a',s)
print a
posted @ 2016-04-08 15:02  FreeMan1  阅读(253)  评论(0编辑  收藏  举报