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