Created
December 9, 2010 18:01
-
-
Save shnya/735066 to your computer and use it in GitHub Desktop.
C++ split: find version
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 string &delim){ | |
vector<string> res; | |
size_t current = 0, found, delimlen = delim.size(); | |
while((found = str.find(delim, current)) != string::npos){ | |
res.push_back(string(str, current, found - current)); | |
current = found + delimlen; | |
} | |
res.push_back(string(str, current, str.size() - current)); | |
return res; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment