@classmethod
def regex(cls, pattern: Union[(Pattern[str], str)], ctx: Optional[commands.Context]=None, channel: Optional[discord.TextChannel]=None, user: Optional[discord.abc.User]=None) -> 'MessagePredicate':
    same_context = cls.same_context(ctx, channel, user)

    def predicate(self: MessagePredicate, m: discord.Message) -> bool:
        if (not same_context(m)):
            return False
        if isinstance(pattern, str):
            pattern_obj = re.compile(pattern)
        else:
            pattern_obj = pattern
        match = pattern_obj.search(m.content)
        if match:
            self.result = match
            return True
        return False
    return cls(predicate)
@classmethod
def regex(cls, pattern: Union[(Pattern[str], str)], ctx: Optional[commands.Context]=None, channel: Optional[discord.TextChannel]=None, user: Optional[discord.abc.User]=None) -> 'MessagePredicate':
    same_context = cls.same_context(ctx, channel, user)

    def predicate(self: MessagePredicate, m: discord.Message) -> bool:
        if (not same_context(m)):
            return False
        if isinstance(pattern, str):
            pattern_obj = re.compile(pattern)
        else:
            pattern_obj = pattern
        match = pattern_obj.search(m.content)
        if match:
            self.result = match
            return True
        return False
    return cls(predicate)