pattern = re.compile('<(\\d{4,5})>')
for i, line in enumerate(open('test.txt')):
    pass
How do I search for a pattern within a text file using Python combining regex & string/file operations and store instances of the pattern?