def rxfilter(rx, select, cursor):
    """Utility function to convert a sequence `cursor` to a generator, but
    applying a filtering predicate to select which rows to return.

    The assumption is that `cursor` yields uniform sequence objects ("rows"),
    and the `select` operator can be invoked with ``select(row)`` for each
    retrieved row to return a string. If the value returned matches the
    regular expression `rx`, the original row is included in the generator
    output, otherwise it's skipped.

    :arg re.RegexObject rx: Regular expression to match against, or at least
     any object which supports ``rx.match(value)`` on the value returned by
     the ``select(row)`` operator.
    :arg callable select: An operator which returns the item to filter on,
     given a row of values, typically an :func:`operator.itemgetter`.
    :arg sequence cursor: Input sequence."""
    for row in cursor:
        if rx.match(select(row)):
            yield row
