- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试解析一些文本以确定它是否是链接。这是我的代码:
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/
这里的 regex_search 只选择本程序中最长的子串,因为输出是整个字符串数据。这是默认行为吗? 此外,如果我像这样传递字符串而不首先将其声明为字符串 regex_search("some da
#include #include int main() { std::string s = "{\"|1|\":\"A\",\"|2|\":\"B\",\"|37|\":\"423423
我尝试传递一对迭代器来表示一个字符串序列: #include #include using namespace std; int main(int argc,char
我正在使用 std::regex 并希望找到与某个用户定义的正则表达式字符串匹配的字符串中的最后一个位置。 例如,给定正则表达式 :.* 和字符串“test:55:last”,我想找到“:last”,
这是我的代码: std::string var = "(1,2)"; std::smatch match; std::regex rgx("[0-9]+"); if(std::regex_search
我正在尝试解析一些文本以确定它是否是链接。这是我的代码: smatch m; regex e("http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(
我正在关注 Stroustrup 的 C++ 之旅 - 第 7.3.1 节(第 79 页)中的示例。此代码在 VS 2013 Update 3 上编译但在运行时失败: regex pat {R"(\w
我今天花了一些时间尝试编写一些 Ansible play,以便仅在相关命令输出中不存在相应行时才运行命令。经过一些试验和错误后,我得到了一些对我有用的东西,但我不清楚为什么我最初与空字符串的比较不起作
如何在 ansible playbook 中使用正则表达式查找匹配项,其中变量出现在 regex_search 中争论? 以下剧本找不到匹配项...运行时使用:ansible-playbook pla
我目前正在努力使用 regex_search 制作一个有效的剧本,我试图让剧本通过网络命令的标准输出(显示运行 vlan ID),然后通过正则表达式来提取所有接口(interface)标记, 最终该变
我刚刚开始学习如何使用regex进行字符串处理(C++11新功能)。如果以下问题太愚蠢,请原谅我。 目前我应用以下代码来获取所有匹配项的索引: string str = "aaabxxxaab"; r
这个问题在这里已经有了答案: Is gcc 4.8 or earlier buggy about regular expressions? (3 个答案) 关闭 6 年前。 当我使用以下代码时,re
我使用各种正则表达式逐行解析 C 源文件。首先,我读取了一个字符串中文件的所有内容: ifstream file_stream("commented.cpp",ifstream::binary); s
关闭。这个问题需要debugging details .它目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and th
考虑以下字符串内容: string content = "{'name':'Fantastic gloves','description':'Theese gloves will fit any ti
这个问题在这里已经有了答案: My regex is matching too much. How do I make it stop? [duplicate] (5 个答案) 关闭 6 年前。 我
我在这方面苦苦挣扎,我已经到了没有取得任何进展的地步,是时候寻求帮助了。我对 boost 库的熟悉程度仅略高于表面。我正在尝试通过一个相当大的字符串进行渐进式扫描。实际上,它是将文件的全部内容读入 s
我正在尝试在 Visual Studio Ultimate 2012 中编译以下代码。它给我一个错误,指出我正在调用模板 regex_search() 不存在的重载。 #include struct
我正在尝试使用正则表达式从字符串中提取版本号。版本号的格式为“D.D.Dc”,其中“D”是数字(可以是一个或多个实例),“c”是可选的字母字符,两侧由空格包围。 我想从中提取的字符串是这样的: FOO
boost::regex re("(abc)(.*?)"); boost::smatch m; std::string str = "abcdlogin"; boost::regex_search(s
我是一名优秀的程序员,十分优秀!