Created
October 19, 2022 12:24
-
-
Save helloobaby/d0d5af29697bafea96c53fe2a353fed8 to your computer and use it in GitHub Desktop.
boost token库 用于字符串分词
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //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