【发布时间】:2015-12-22 07:15:19
【问题描述】:
我对下面的 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;
}
我希望它打印出3,但我得到的是1。我错过了什么吗?
【问题讨论】:
-
每次搜索只能获得 1 个匹配项。