Skip to content

Instantly share code, notes, and snippets.

@helloobaby
Created October 19, 2022 12:24
Show Gist options
  • Select an option

  • Save helloobaby/d0d5af29697bafea96c53fe2a353fed8 to your computer and use it in GitHub Desktop.

Select an option

Save helloobaby/d0d5af29697bafea96c53fe2a353fed8 to your computer and use it in GitHub Desktop.
boost token库 用于字符串分词
//https://stackoverflow.com/questions/7941725/boosttokenizer-comma-separated-c
#include <iostream>
#include <exception>
#include <vector>
#include <algorithm>
#include <cassert>
#include <boost/tokenizer.hpp>
using namespace std;
int main(int ac, char* av[]) {
using namespace std;
using namespace boost;
string s = "username : sbb;age : 10;";
boost::char_separator<char> sep(";");
boost::tokenizer<boost::char_separator<char> > tok(s, sep);
for (boost::tokenizer<boost::char_separator<char> >::iterator beg =
tok.begin();
beg != tok.end(); ++beg) {
cout << *beg << "\n";
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment