fork download
  1. import re
  2.  
  3. def num_format(T):
  4. clean_number = ''.join(c for c in T if c.isdigit())
  5. return re.sub(r'(\d{3})(?=\d{2})|(?<=\d{2})(?=\d{2}$)', r'\1-', clean_number)
  6.  
  7. print(num_format("05553--70002654"))
Success #stdin #stdout 0.02s 9752KB
stdin
Standard input is empty
stdout
055-537-000-26-54