gpt4 book ai didi

c++ - std::regex_match 的结果似乎是错误的

转载 作者:行者123 更新时间:2023-11-28 02:04:19 27 4
gpt4 key购买 nike

<分区>

我试图理解以下代码的行为。

我认为这可能是一个错误,因为结果对我来说是错误的。

#include <iostream>
#include <regex>

int main(int ac, char **av)
{
std::regex reg("lib(.*)\\.so");
std::smatch match;
std::cout << std::regex_match(std::string("libscio.so"), match, reg) << std::endl;
std::cout << match.str(1) << std::endl;

return 0;
}

我很期待

1
scio

但它给了我

1
ocio

在 x86_64 GNU/Linux 上使用 gcc 版本 4.9.2 (Debian 4.9.2-10) 编译

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