import re
string = "机器学习359.67.pdf机器学习111.67.txt"
a = re.findall("D*(.*?).[a-z*]",string)
print(a)
b = re.findall("D*(.*?).D+",string)
print(b)
c = re.findall("(.*?.pdf|.*?.txt)",string)
print(c)
结果:
[‘359.67’, ‘111.67’]
[‘359.67’, ‘111.67’]
[‘机器学习359.67.pdf’, ‘机器学习111.67.txt’]