Your program is not the same as mine.
Paste my sample and run it.
Paste my sample and run it.
#!/usr/bin/python3 import re pattern = r""" tel: # tel: \s*? # maybe some spaces \+44 # +44 \s*? # maybe some spaces (\d{10,10}) # 10 digits """ with open ('phone_log.txt') as in_file: for linenr, line in enumerate(in_file): match = re.search(pattern, line, re.X) if match: print("Line %d: %s" % (linenr, match.group(1))) #done