def regex(self, *patterns, **kwargs):
start = kwargs.pop("<STR_LIT:start>", <NUM_LIT:0>)<EOL>stop = kwargs.pop("<STR_LIT>", None)<EOL>keys_only = kwargs.pop("<STR_LIT>", False)<EOL>flags = kwargs.pop("<STR_LIT>", <NUM_LIT:0>)<EOL>results = {pattern: [] for pattern in patterns}<EOL>stop = stop if stop is not None else -<NUM_LIT:1><EOL>for i, line in enumerate(self[start:stop]):<EOL><INDENT>for pattern in patterns:<EOL><INDENT>grps = re.search(pattern, line, flags=flags)<EOL>if grps and keys_only:<EOL><INDENT>results[pattern].append(i)<EOL><DEDENT>elif grps and grps.groups():<EOL><INDENT>for group in grps.groups():<EOL><INDENT>results[pattern].append((i, group))<EOL><DEDENT><DEDENT>elif grps:<EOL><INDENT>results[pattern].append((i, line))<EOL><DEDENT><DEDENT><DEDENT>if len(patterns) == <NUM_LIT:1>:<EOL><INDENT>return results[patterns[<NUM_LIT:0>]]<EOL><DEDENT>return results<EOL>
Search the editor for lines matching the regular expression.
re.MULTILINE is not currently supported.

Args:
    \*patterns: Regular expressions to search each line for
    keys_only (bool): Only return keys
    flags (re.FLAG): flags passed to re.search

Returns:
    results (dict): Dictionary of pattern keys, line values (or groups - default)