问题描述
我正在 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 正则匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)