【发布时间】:2016-12-12 20:45:34
【问题描述】:
我已经尝试了代码的注释和未注释版本:
string separator1(""); //dont let quoted arguments escape themselves
string separator2(",\n"); //split on comma and newline
string separator3("\"\'"); //let it have quoted arguments
escaped_list_separator<char> els(separator1, separator2, separator4);
tokenizer<escaped_list_separator<char>> tok(str);//, els);
for (tokenizer<escaped_list_separator<char>>::iterator beg = tok.begin();beg!= tok.end(); ++beg) {
next = *beg;
boost::trim(next);
cout << counter << " " << next << endl;
counter++;
}
分离具有以下格式的文件:
12345, Test Test, Test
98765, Test2 test2, Test2
这是输出
0 12345
1 Test Test
2 Test
98765
3 Test2 test2
4 Test2
我不确定问题出在哪里,但我需要实现的是在 98765 之前有一个数字 3
【问题讨论】: