#include<iostream> #include<boost/tokenizer.hpp> #include<string> using namespace std; using namespace boost; int main() { { string s = "12252001"; int offsets[] = {2, 2, 4}; offset_separator f(offsets, offsets + 3); tokenizer<offset_separator> tok(s, f); for (tokenizer<offset_separator>::iterator beg = tok.begin(); beg != tok.end(); ++beg) { cout << *beg << "\n"; } } { string s = "Field 1,\"putting quotes around fields, allows commas\",Field 3"; tokenizer<escaped_list_separator<char> > tok(s); for (tokenizer<escaped_list_separator<char> >::iterator beg = tok.begin(); beg != tok.end(); ++beg) { cout << *beg << "\n"; } } { string s = "This is, a test"; tokenizer<> tok(s); for (tokenizer<>::iterator beg = tok.begin(); beg != tok.end(); ++beg) { cout << *beg << "\n"; } } }
4 年前
0 意見:
張貼留言