<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def filter_data(data, filter_dict):
 """ filter a data dictionary for values only matching the filter """

    for key, match_string in filter_dict.items():
        if key not in data:
            logger.warning("{0} doesn't match a top level key".format(key))
            continue
        values = data[key]
        matcher = re.compile(match_string)
        if isinstance(values, list):
            values = [v for v in values if matcher.search(v)]
        elif isinstance(values, dict):
            values = dict((k, v) for k, v in values.items() if matcher.search(k))
        else:
            raise MiuraException("cannot filter a {0}".format(type(values)))
        data[key] = values