2014年3月27日 星期四

Complete Example of using a string as delimiter to parse (split) a string

/*
** Complete Example of using a string as delimiter to parse (split) a string
**
std::string s = "scott>=tiger>=mushroom";
std::string delimiter = ">=";

size_t pos = 0;
std::string token;
while ((pos = s.find(delimiter)) != std::string::npos) {
token = s.substr(0, pos);
std::cout << token << std::endl;
s.erase(0, pos + delimiter.length());
}
std::cout << s << std::endl;
*/

http://stackoverflow.com/questions/14265581/parse-split-a-string-in-c-using-string-delimiter-standard-c

沒有留言:

張貼留言