import re input = open('test.txt').read() print input #m = re.search(r'(?<=((.*?)""", input): if match[0] != match[3]: print match, "mismatches"