import re
pattern = "(top)(\s*)(\d+)"
input_str = "what is the top 5 ?"
match = re.findall(pattern, input_str)
print(match)
print结果:
[('top', ' ', '5')]
import re
pattern = "(top)(\s*)(\d+)"
input_str = "what is the top 5 ?"
match = re.findall(pattern, input_str)
print(match)
print结果:
[('top', ' ', '5')]