【发布时间】:2017-04-06 09:08:56
【问题描述】:
#include <regex>
#include <string>
#include <iostream>
using namespace std;
bool IsMatched()
{
string str = R"(Liy_0-3863)";
string re = R"([:\-_a-zA-Z\d]+)";
auto flags = std::regex_constants::ECMAScript;
return std::regex_match(str.data(),
std::regex(re.data(), re.size(), flags));
}
int main()
{
cout << boolalpha << IsMatched();
}
-
clang 4.0 输出
true; -
gcc 6.2 输出
false。
这是谁的错误 - clang 还是 gcc?
【问题讨论】:
-
GCC 中继打印
true,所以我认为答案是显而易见的。 -
问题标题非常具有误导性。这个问题永远无法通过搜索找到。请使标题更能描述问题,并在关键字中添加正则表达式。
-
@Ryan 就是这个\-
标签: c++ c++11 gcc clang standards