1、通配符匹配次数

import re

key = r"saasandsasandsaaas"
p = r"sa{1,2}s"
pattern = re.compile(p1)printpattern1.findall(key)

#out
# ['saas', 'sas']
# 如果 {1,}则表示至少匹配1次
# 如果 {,2} 则表示最多匹配2次

 

posted on 2021-09-21 15:18  wulc++  阅读(19)  评论(0编辑  收藏  举报