#include <fstream>
#include <iostream>
#include <string>
#include <vector>
std::vector<std::string> tokenize(const std::string& line, const std::string& delimiters)
{
std::vector<std::string> tokens;
std::size_t token_start = 0;
auto const npos = std::string::npos;
while ((token_start = line.find_first_not_of(delimiters, token_start)) != npos)
{
auto token_end = line.find_first_of(delimiters, token_start);
auto len = token_end == npos ? line.size() - token_start : token_end - token_start;
tokens.push_back(line.substr(token_start, len));
token_start = token_end;
}
return tokens;
}
int main()
{
auto tokens = tokenize("one.two three,4.5 six seven,eight.9.ten", " ,.");
for (auto& token : tokens)
std::cout << token << '\n';
}
I2luY2x1ZGUgPGZzdHJlYW0+CiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPHZlY3Rvcj4KCnN0ZDo6dmVjdG9yPHN0ZDo6c3RyaW5nPiB0b2tlbml6ZShjb25zdCBzdGQ6OnN0cmluZyYgbGluZSwgY29uc3Qgc3RkOjpzdHJpbmcmIGRlbGltaXRlcnMpCnsKICAgIHN0ZDo6dmVjdG9yPHN0ZDo6c3RyaW5nPiB0b2tlbnM7CiAgICBzdGQ6OnNpemVfdCB0b2tlbl9zdGFydCA9IDA7CiAgIAogICAgYXV0byBjb25zdCBucG9zID0gc3RkOjpzdHJpbmc6Om5wb3M7CiAgICB3aGlsZSAoKHRva2VuX3N0YXJ0ID0gbGluZS5maW5kX2ZpcnN0X25vdF9vZihkZWxpbWl0ZXJzLCB0b2tlbl9zdGFydCkpICE9IG5wb3MpCiAgICB7CiAgICAgICAgYXV0byB0b2tlbl9lbmQgPSBsaW5lLmZpbmRfZmlyc3Rfb2YoZGVsaW1pdGVycywgdG9rZW5fc3RhcnQpOwogICAgICAgIGF1dG8gbGVuID0gdG9rZW5fZW5kID09IG5wb3MgPyBsaW5lLnNpemUoKSAtIHRva2VuX3N0YXJ0IDogdG9rZW5fZW5kIC0gdG9rZW5fc3RhcnQ7CgogICAgICAgIHRva2Vucy5wdXNoX2JhY2sobGluZS5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