with open('inputfile') as f:
    for line in f:
        match = regex.match(line)
if match:
    result.append([match.group('name'), match.group('email'), match.group(
        'previous')])
Parsing text files using Python