Skip to content

Instantly share code, notes, and snippets.

@tadamatu
Created July 25, 2015 01:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tadamatu/cb73564bddd3cfac338e to your computer and use it in GitHub Desktop.
Save tadamatu/cb73564bddd3cfac338e to your computer and use it in GitHub Desktop.
トリミング関数
//[cocos2d-x]
//トリミング関数
//str 対象文字列
//[trimCharacterList] トリミングしたい文字
//Return トリミング後の文字列
std::string trim(const std::string& str, const char* trimCharacterList = "; \t\v\r\n\"\'") {
std::string result;
std::string::size_type left = str.find_first_not_of(trimCharacterList);
if (left != std::string::npos) {
std::string::size_type right = str.find_last_not_of(trimCharacterList);
result = str.substr(left, right - left + 1);
}
return result;
}
@tadamatu
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment