相关疑难解决方法(0)

std :: match_results :: size返回什么?

我对以下C++ 11代码感到有点困惑:

#include <iostream>
#include <string>
#include <regex>

int main()
{
    std::string haystack("abcdefabcghiabc");
    std::regex needle("abc");
    std::smatch matches;
    std::regex_search(haystack, matches, needle);
    std::cout << matches.size() << std::endl;
}
Run Code Online (Sandbox Code Playgroud)

我希望它打印出来,3但我得到了1.我错过了什么吗?

c++ regex c++11

8
推荐指数
2
解决办法
2112
查看次数

标签 统计

c++ ×1

c++11 ×1

regex ×1