import re


def enum(iterable, filt=None, invert=True):
    """
    Enumerate an iterable for interactive use. return it as a list. Optional negative filter supplied as regex
    :param iterable:
    :param filt:
    :param invert: [True] sense of filter. note default is negative i.e. to screen *out* matches
     (the thinking is that the input is already positive-filtered)
    :return:
    """
    ret = []
    if filt is not None:
        if invert:
            _iter = filter(lambda x: not bool(re.search(filt, str(x), flags=re.I)), iterable)
        else:
            _iter = filter(lambda x: bool(re.search(filt, str(x), flags=re.I)), iterable)
    else:
        _iter = iterable
    for k, v in enumerate(_iter):
        print(' [%02d] %s' % (k, v))
        ret.append(v)
    return ret