c++ - 使用 regex_search

标签 c++ boost

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

    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/

相关文章:

c++ - boost::arm64 的上下文?

c++ - 如何指向 shared_ptr

c++ - 为什么在线程中使用 system() 时,多线程 C 程序会在 Mac OS X 上强制使用单个 CPU?

c++ - 如何使用密码而不是 openssl 库中的 key 和 iv 通过 AES-256-CBC 加密文件?

c++ - Boost:反序列化通过 ZeroMQ pull socket 传递的自定义 C++ 对象

c++ - 如何在不完全 boost 的情况下使用 boost.xpressive ?

c++ - 位掩码作为具有默认参数的成员枚举

c++ - 在 C++ 中使用运算符删除的段错误

c++ - 尝试包装函数返回值时出现 "<class name> does not provide a call operator"错误

c++ - 使用 cmake 2.8.8 链接 boost 库