Created
July 25, 2015 01:49
-
-
Save tadamatu/cb73564bddd3cfac338e 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
//[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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://tadamatu.blogspot.jp/2015/07/cocos2dtrim.html