环境:python3

#re模块的常用方法:

re.match(r'\d','123a')

<_sre.SRE_Match object; span=(0, 1), match='1'>

print (re.match(r'\d','b123a'))

None



re.search(r'\d','b35f3')

<_sre.SRE_Match object; span=(1, 2), match='3'>

c = re.search(r'\d','b35f3')

c

<_sre.SRE_Match object; span=(1, 2), match='3'>



re.findall(r'\d','b35f3')

['3', '5', '3']

re.sub('i','o','pythin pythin pythin pythin')

'python python python python'


re.sub('i','o','pythin pythin pythin pythin',2)

'python python pythin pythin'

re.sub('\w','o','pythin pythin pythin pythin')

'oooooo oooooo oooooo oooooo'

re.sub('\w','o','pythin pythin pythin pythin',2)

'oothin pythin pythin pythin'

re.sub('\d','o','pythinsfsf12334dff4545')

'pythinsfsfooooodffoooo'

re.sub('\d','o','pythinsfsf12334dff4545',5)

'pythinsfsfooooodff4545'









未完待续。。。