fork download
  1. import re
  2.  
  3. regex = r"(?:\b(?:Ph(?:one)?|tel(?:ephone)?)\b.{0,50}\b([0-9]{3}-[0-9]{3}[-][0-9]{4})\b|\b([0-9]{3}-[0-9]{3}[-][0-9]{4})\b.{0,50}(?:(?:Ph(?:one)?|tel(?:ephone)?)\b))"
  4.  
  5. test_str = "This is my Phone number and I am 25 years old, 999-888-7894 and I am looking for a regex script. however my new Phone number is 722-818-7994. well thanks for the regex that i have got from the site stackoverflow"
  6.  
  7. print(re.findall(regex, test_str))
Success #stdin #stdout 0.02s 9636KB
stdin
Standard input is empty
stdout
[('999-888-7894', ''), ('722-818-7994', '')]