python 匹配固定字串+后面的数字

import re

pattern = "(top)(\s*)(\d+)"

input_str = "what is the top 5 ?"

match = re.findall(pattern, input_str)

print(match)

print结果:
[('top', ' ', '5')]

发布了1142 篇原创文章 · 获赞 196 · 访问量 260万+

猜你喜欢

转载自blog.csdn.net/guotong1988/article/details/103332950