pyhton 正则表达式 findall()方法只写出了一个号码
你另一个号码,尾号不是4位,是3位,当然没办法匹配出来
import re
phoneNumRegex = re.compile(r'(\d\d\d)-(\d\d\d)-(\d\d\d\d)')
text = 'Cel1:415-555-999 Work:212-555-0000'
matches = phoneNumRegex.findall(text)
print(matches)
import re
# \d{3} 表示有3个数字 ; \d{3,4}表示有3或者4个数字
phoneNumRegex = re.compile(r'(\d{3})-(\d{3})-(\d{3,4})')
result = phoneNumRegex.findall('Cel1:415-555-999 Work:212-555-0000')
print(result)