import re


def _filter_metrics(metrics, exclude):
    """Exclude metrics matching a list of regexp."""
    for pattern in exclude:
        regex = re.compile(pattern)
        metrics = [m for m in metrics if not regex.search(m)]
    return metrics