gpt4 book ai didi

C++11 正则表达式与字符串不匹配

转载 作者:太空狗 更新时间:2023-10-29 21:22:41 26 4
gpt4 key购买 nike

<分区>

我想解析一个如下所示的标记:

1111111111111111:1384537090:Gl21j08WWBDUCmzq9JZoOXDzzP8=

我使用正则表达式 ([0-9]{16}):([0-9]{5,20}):([a-zA-Z0-9\\+/=] {28}),当我在 refiddle 上尝试时,它就完成了工作.

然后我用 C++ 试试:

std::regex regexp(R"(([0-9]{16}):([0-9]{5,20}):([a-zA-Z0-9\\+/=]{28}))", 
std::regex_constants::basic);
std::smatch match;

if (std::regex_search(stringified, match, regexp)) {
cout << match[0] << ',' << match[1] << ',' << match[2] << endl;
} else {
cout << "No matches found" << endl;
}

我使用带有 -std=c++11 标志的 GCC 4.8.1 在 Ubuntu 13.10 x64 上编译它。但我总是得到 No matches found。我做错了什么?

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com