python:re.findall用法

正则 re.findall 的简单用法(返回string中所有与pattern相匹配的全部字串,返回形式为数组)

语法

  findall(pattern, string, flags=0)

代码

import re

line = 'Cats are smarter than dogs dogs'


matchObj = re.findall('dogs', line)
if matchObj:
print('use search,the match string is:', matchObj)
else:
print('No search match string!!')

结果

posted @ 2021-11-09 15:57  Tester-**  阅读(243)  评论(0编辑  收藏  举报