fork download
  1. import re
  2. text = """John................. .............222-333-4447....... .. 423-444-5678 .... .................123-455-1223............... ........Paul... ......423-444-5778....................................... –
  3. Nithin"""
  4. pattern=r"(\w+)((?:[\s:.]*\d+[-—–]\d+[-—–]\d+)+)"
  5. print( [(x, " ".join(y.replace('.','').split())) for x,y in re.findall(pattern, text)] )
Success #stdin #stdout 0.03s 9532KB
stdin
Standard input is empty
stdout
[('John', '222-333-4447 423-444-5678 123-455-1223'), ('Paul', '423-444-5778')]