Oct-27-2017, 02:05 PM
(Oct-27-2017, 01:53 PM)heiner55 Wrote: That is ok.
Ok that's great, so my code is the following:
>>> data_file = open("phone_log.txt", "r")
>>> data = data_file.readlines()
>>> import re
>>> pattern = re.compile(r'''tel:\s*?\+44\s*?\d{10,10}''', re.X)
>>> uk_numbers =[]
>>> with open( 'phone_log.txt') as in_file:
for linenum, line in enumerate(in_file):
if pattern.search(line) != None:
uk_numbers.append((linenum, line.rstrip('\n')))
>>> for linenum, line in uk_numbers:
print("Line", linenum, ":", line)
What must I do to print the UK phone numbers? Would be great if I could know this since I've been trying for the past hour and not succeeding
Very much appreciated for your help