def highlight(text, expression, color):
    """
    Uses ANSI color codes to highlight matches of the given regular `expression`
    in `text`.
    """
    return expression.sub(lambda m: '\x1b[' + color + 'm' + m.group(0) +
        '\x1b[0m', text)
