import re


def replace_line(file_contents, replacements):
    """Replaces lines in a file with a new line, based on search
    expressions.

    PARAMETERS
    ----------
    'file_contents': The string contents of the file to alter.
    'replacements': A list of two-tuples describing the replacements.
        The first item in the tuple is a RegEx search expression identifying
        a line to be replaced; the second tuple item is the the new line to
        substitute.
    RETURNS
    -------
    The altered contents of the file.  Uses Linux line endings.
    If the setting is not found in the contents, the contents are not
    altered.
    """

    lines = file_contents.splitlines()
    new_lines = []
    for line in lines:
        sub_made = False
        for match_expr, new_line in replacements:
            if re.search(match_expr, line):
                new_lines.append(new_line)
                sub_made = True
                break
        if not sub_made:
            new_lines.append(line)

    return chr(10).join(new_lines)