-
-
Save ilpropheta/6b7a3941f96884df6a5416ee7c39ea39 to your computer and use it in GitHub Desktop.
This file contains 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
vector<string> split(const string& str, const char* delims) | |
{ | |
vector<string> ret; | |
string::size_type start = 0; | |
auto pos = str.find_first_of(delims, start); | |
while (pos != string::npos) | |
{ | |
if (pos != start) | |
{ | |
ret.push_back(str.substr(start, pos - start)); | |
} | |
start = pos + 1; | |
pos = str.find_first_of(delims, start); | |
} | |
if (start < str.length()) | |
ret.push_back(str.substr(start, str.length() - start)); | |
return ret; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment