I expect I'm misunderstanding the description at cppreference, but could someone explain why the following code:
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;
}
outputs just two submatches:
submatch = 'one'
submatch = 'two'
rather than also including an empty suffix iterator submatch for the empty string following the last comma?
submatch = ''
Encountered using Visual C++ 2017 and /std:c++17 if that makes any difference.
Aucun commentaire:
Enregistrer un commentaire