1 import re 2 m = re.search(‘[0-9]‘,‘ab45cf‘) 3 print(m.group(0))#4.完全匹配用match 4 str = re.sub(‘[0-9]‘, ‘f‘, ‘df34gg‘) 5 print str#dfffgg 6 m = re.findall(‘[0-9]‘,‘54dgg5t‘) 7 print m 8 m = re.split(‘[0-9]‘,‘dgg55t‘) 9 print m
4
dfffgg
[‘5‘, ‘4‘, ‘5‘]
[‘dgg‘, ‘‘, ‘t‘]