相关疑难解决方法(0)

使用C++ 11 regexp和gcc 4.8.2时的结果很奇怪(但与Boost regexp配合使用)

我尝试使用C++ 11的正则表达式,但即使在简单的例子中也失败了.从外面看,似乎只比较字符串,例如:

std::regex_match(std::string{""}, std::regex{"a?"})   // false (???)
std::regex_match(std::string{"a?"}, std::regex{"a?"}) // true  (???)
Run Code Online (Sandbox Code Playgroud)

相比之下,Boost的regexp库的行为与我预期的一样:

boost::regex_match(std::string{""}, boost::regex{"a?"})   // true  (OK)
boost::regex_match(std::string{"a?"}, boost::regex{"a?"}) // false (OK)
Run Code Online (Sandbox Code Playgroud)

我使用GCC 4.8.2和clang 3.4(也使用GCC的STL库)进行了测试.库已损坏,或者我不理解C++ 11标准定义的语法.

c++ regex gcc c++11 gcc4.8

8
推荐指数
1
解决办法
7818
查看次数

标签 统计

c++ ×1

c++11 ×1

gcc ×1

gcc4.8 ×1

regex ×1