Below is my code
string str2 = "1, 2, 3, 4, 5, 6, 7, 8";
string output;
typedef std::tr1::sregex_token_iterator sti;
const sti end;
for(sti i(str2.begin(), str2.end(), regex(",\\s"), -1); i != end; ++i)
{
//output += "\"" + *i + "\", ";
output += "\"";
output += *i;
output += "\", ";
}
cout<<output.substr(0, output.length() - 2)<<endl;
the result is
"1", "2, 3, 4, 5, 6, 7, 8"
But what I expected was
"1", "2", "3", "4", "5", "6", "7", "8"
How could I solve the problems?
Thanks a lot
ps:i am using the <regex> library of visual c++ 2008