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)
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)