Skip to content

Instantly share code, notes, and snippets.

@divegeek
Created June 26, 2016 22:50
Show Gist options
  • Save divegeek/495ac312f24e94cd00580aae9ee61fb0 to your computer and use it in GitHub Desktop.
Save divegeek/495ac312f24e94cd00580aae9ee61fb0 to your computer and use it in GitHub Desktop.
std::vector<std::string> split(const std::string &text, char sep) {
std::vector<std::string> tokens;
std::size_t start = 0, end = 0;
while ((end = text.find(sep, start)) != std::string::npos) {
tokens.push_back(text.substr(start, end - start));
start = end + 1;
}
tokens.push_back(text.substr(start));
return tokens;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment