Jun-09-2021, 03:38 PM
Do a check for when the match fails, then print out the line in question. If you don't understand why the match fails, you can ask about it.
Also, why are you matching every line in the text file, but then only printing out the match that happens on the last line?
Also, why are you matching every line in the text file, but then only printing out the match that happens on the last line?
import re with open('testregpad.txt') as f: for line in f: match = re.search('event\);\">(.*)<\/a.*', line) if match: print(match.group(1)) else: print(f"Failed to find a match in line: {line}")