#!/usr/bin/env python
import os
import re
import sys
filename=sys.argv[1]
fd=open(filename,"r")
index=1
for row in fd.readlines() :
a=re.compile( r"^(?P<region>\d{3}-|\(\d{3}\) )(?P<numes>\d{3})-(?P<tails>\d{4})" )
b = a.match( row )
if b:
print( index ,b.groups() )
index=index+1
example
123-456-7890
(123) 456-7890
123 -
(123 )
因篇幅问题不能全部显示,请点此查看更多更全内容