import re


def remove_index_types(data):
    """
    Replace the index type in expressions containing "extractelement" or "insertelement" by token <TYP>
    :param data: input data as a list of files where each file is a list of strings
    :return: modified input data
    """
    print('\tRemoving index types ...')
    for i in range(len(data)):
        for j in range(len(data[i])):
            if re.match("<%ID> = extractelement", data[i][j]) is not None or \
                    re.match("<%ID> = insertelement", data[i][j]) is not None:
                data[i][j] = re.sub(r'i\d+ ', '<TYP> ', data[i][j])

    return data