Discord Python - 在 message.content 中搜索正则表达式并忽略它之前或之后的任何内容

Discord Python - Search for regex in message.content and ignore anything before it or after

async def on_message(self, message):
    streamables = re.compile(r'streamable(\.com)\/([\w-]{2,50})')
    if streamables.search(message.content) and message.channel.id == 363835464219754498:
        url = message.content
        print(url)

我希望它只显示 link,即使它之前或之后有内容。我该怎么做?

存储streamables.search(message.content)的结果得到匹配对象,然后调用group()抓取匹配到的东西。

async def on_message(self, message):
    streamables = re.compile(r'streamable(\.com)\/([\w-]{2,50})')
    match = streamables.search(message.content)
    if match and message.channel.id == 363835464219754498:
        url = match.group()
        print(url)