@pipe.func<EOL>def grep(prev, pattern, *args, **kw):
inv = False if '<STR_LIT>' not in kw else kw.pop('<STR_LIT>')<EOL>pattern_obj = re.compile(pattern, *args, **kw)<EOL>for data in prev:<EOL><INDENT>if bool(inv) ^ bool(pattern_obj.match(data)):<EOL><INDENT>yield data<EOL><DEDENT><DEDENT>
The pipe greps the data passed from previous generator according to
    given regular expression.

    :param prev: The previous iterator of pipe.
    :type prev: Pipe
    :param pattern: The pattern which used to filter out data.
    :type pattern: str|unicode|re pattern object
    :param inv: If true, invert the match condition.
    :type inv: boolean
    :param kw:
    :type kw: dict
    :returns: generator