更新时间:2023-11-07 12:20:04
您可以使用简单的 (\d+)M
正则表达式(1+ digit(s) 后跟 M
使用 re.findall
将数字捕获到捕获组中.
You may use a simple (\d+)M
regex (1+ digit(s) followed with M
where the digits are captured into a capture group) with re.findall
.
参见 IDEONE 演示:
import re
s = "107S33M15H\n33M100S\n12M100H33M"
print(re.findall(r"(\d+)M", s))
这是一个正则表达式演示