#include <iostream> 
#include <string>

int main()
{
	std::string sentence = "hello,potato tomato.";
	std::string delims = " .,";

	size_t beg, pos = 0;
	while ((beg = sentence.find_first_not_of(delims, pos)) != std::string::npos)
	{
		pos = sentence.find_first_of(delims, beg + 1);
		std::cout << sentence.substr(beg, pos - beg) << std::endl;
	}
}