身思乐,人事爱,稳恒不言败!

python re 正则

import re

content = "Hello 1234567 World_ This is a Regex Demo"
result = re.match("^Hello\s(\d+)\sWorld.*Demo$", content)
print(result)
print(result.group(1))
print(result.span())

输出
<_sre.SRE_Match object at 0x7ffafb0516c0>
1234567
(0, 41)