缺少std :: regex_token_iterator的空后缀迭代器?

时间:2018-12-21 13:44:27

标签: c++ regex c++11 iterator

我希望我误解了说明at cppreference,但有人可以解释以下代码的原因:

std::regex comma(",");
std::string string("one,two,");
std::sregex_token_iterator begin{ string.begin(), string.end(), comma, -1 }, end;
for (auto it = begin; it != end; ++it)
{
    std::cout << "submatch = '" << it->str() << "'" << std::endl;
}

仅输出两个子匹配项:

submatch = 'one'
submatch = 'two'

不是在最后一个逗号之后为空字符串包括空后缀迭代器子匹配吗?

submatch = ''

遇到问题时使用Visual C ++ 2017和/ std:c ++ 17。

0 个答案:

没有答案