fork download
  1. import re
  2.  
  3. regex = r"\b(?:03|7[016])[- /]?\d{3} ?\d{3}\b"
  4.  
  5. test_str = ("03-123456\n"
  6. "03123456\n"
  7. "03 123 456 \n"
  8. "03 123456\n"
  9. "03/123456\n\n"
  10. "Hi my name is marc and my phone number is 03-123456 and i would like 2 bottles of water 0.5L")
  11.  
  12. print(re.findall(regex, test_str))
Success #stdin #stdout 0.02s 9620KB
stdin
Standard input is empty
stdout
['03-123456', '03123456', '03 123 456', '03 123456', '03/123456', '03-123456']