Oct-27-2017, 03:32 PM
(Oct-27-2017, 02:28 PM)heiner55 Wrote: Maybe this helps: https://docs.python.org/3.6/library/re.html
#!/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 ", linenr, ": ", match[1], sep='')phone_log.txt:
here is some text "tel:+44 1234567890" hers is some text
tel: +44 1234567890 text text
text tel text tel: +441234567890 text
tel:+441234567890
Output:Line 0: 1234567890 Line 1: 1234567890 Line 2: 1234567890 Line 3: 1234567890
Ahh,yes
as in, how do i get that output? what must i do to get that output ?