Last active
April 15, 2016 07:29
-
-
Save tkymx/6e910363cb04aa3eef3e0e0d644ea062 to your computer and use it in GitHub Desktop.
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
std::vector<std::string> split(std::string text,std::string delim ) | |
{ | |
int index = 0, current = 0; | |
std::vector<std::string> strs; | |
while ((index = text.find_first_of(delim, current)) != std::string::npos) | |
{ | |
strs.push_back(text.substr(current, index - current)); | |
current = index + 1; | |
} | |
strs.push_back(text.substr(current,text.size()-current)); | |
return strs; | |
} |
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
std::string trim(std::string text ) | |
{ | |
int r = text.find_first_not_of(" \t"); | |
int l = text.find_last_not_of(" \t"); | |
if (r == std::string::npos || l == std::string::npos) | |
return text; | |
return text.substr(r,l-r+1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment