human
I wrote the below code

    if _isstring(regex):
        regex = re.compile(regex)
    def f(msg):
        text = extractor(msg)
        match = regex.search(text)
        if match:
            index = (key if isinstance(key, tuple) else (key,))
            return (match.group(*index), (match,))
        else:
            return ((None,),)
    return f

What's a good function header?
assistant
#Here's a good function header.

def by_regex(extractor, regex, key=1):