Created
July 25, 2015 01:46
-
-
Save tadamatu/e18063aa519b07bde76f 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] | |
//文字列の置換 | |
//target 対象文字列 | |
//from 検索する文字列(置換される文字列) | |
//to 置換する文字列 | |
//Return 置換後文字列 | |
std::string stringReplace(const std::string target, const std::string from, const std::string to) { | |
std::string result = target; | |
std::string::size_type pos = 0; | |
while(pos = result.find(from, pos), pos != std::string::npos) { | |
result.replace(pos, from.length(), to); | |
pos += to.length(); | |
} | |
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/cocos2d-xreplace.html