立即学习:https://edu.csdn.net/course/play/26755/340147?utm_source=blogtoedu
search函数:
import re
s1 = re.search("(\d{3})-(\d{7,})-(\d{3,})", 123-12345678-1234)
if s1 is not None:
print(s1.group())
print(s1.groups()[0])
print(s1.groups()[1])
print(s1.groups()[2])
"""结果:
123-12345678-1234
123
12345678
1234 """