import re


def filter_lines_regex(lines, regex, substitute):
    """
    Substitutes `substitute` for every match to `regex` in each line of
    `lines`.

    Parameters
    ----------

    lines : iterable of strings

    regex, substitute : str
    """
    return [re.sub(regex, substitute, line) for line in lines]