C++11 Regex Matching(C++11 正则匹配)
问题描述
我正在 C++11(使用 gcc 4.7.2)中尝试一个相当简单的正则表达式匹配,但是我遇到了很多麻烦.尝试使用
I'm attempting a fairly simple regex match in C++11 (using gcc 4.7.2), but I'm having a large amount of trouble. Attempting to construct a pattern using
std::regex unquoted(R"regex(s*([^",]+)s*)regex");
导致构造函数抛出一个 std::regex_error
异常,代码为 std::regex_constants::error_escape
.几个在线正则表达式测试者对相同的表达式没有问题,我尝试使用不同的一些不同的语法选项无济于事.C++ 正则表达式语法有什么根本不同的地方我没有掌握?
causes the constructor to throw a std::regex_error
exception with the code std::regex_constants::error_escape
. Several regex testers online have no problem with the same expression, and I've tried using different some of the different syntax options to no avail. Is there something fundamentally different about the C++ regex syntax that I'm not grasping?
推荐答案
参见 gcc 的 stdc++11 实现状态页面 -- 自 gcc 4.8 起不支持正则表达式
See gcc's stdc++11 implementation status page -- regexes are not supported as of gcc 4.8
为后代正如评论中提到的,正则表达式库现在在 libstdc++
中,应该在 gcc 4.9 及更高版本中.
Edit for posterity: As mentioned in the comments, the regex library is now in libstdc++
and should be in gcc 4.9 and on.
这篇关于C++11 正则匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:C++11 正则匹配


基础教程推荐
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 这个宏可以转换成函数吗? 2022-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 常量变量在标题中不起作用 2021-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 我有静态或动态 boost 库吗? 2021-01-01