gpt4 book ai didi

c++ - 使用 regex_search

转载 作者:行者123 更新时间:2023-11-28 07:14:23 27 4
gpt4 key购买 nike

我正在尝试解析一些文本以确定它是否是链接。这是我的代码:

    smatch m;
regex e("http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+");
bool match = regex_search(proto->message, m, e);
if(match == true) {
chan->Say("Matched link");
}

我得到的错误是:

/main.cpp|26|error: no matching function for call to ‘regex_search(char [1024], boost::smatch&, boost::regex&)’|

当我从 regex_search 中取出 m 时,它起作用并返回一个 boolean,但我想知道实际匹配是什么。

最佳答案

Boost 的 regex_search 没有定义您尝试使用的签名。在所有重载中都没有 boost::smatch 第二个参数。事实上,smatch 根本没有被使用。参见 docs尤其是页面底部的示例。

关于c++ - 使用 regex_search,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20457685/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com