Skip to content

Instantly share code, notes, and snippets.

@syuhari
Created May 17, 2015 20:55
Show Gist options
  • Save syuhari/4fab863c37da595f049c to your computer and use it in GitHub Desktop.
Save syuhari/4fab863c37da595f049c to your computer and use it in GitHub Desktop.
string 文字列の中にある指定の文字列を繰り返し置換する
std::string replaceString(std::string string1, std::string string2, std::string string3)
{
std::string::size_type pos(string1.find(string2));
while(pos!=std::string::npos) {
string1.replace(pos, string2.length(), string3);
pos = string1.find(string2, pos + string3.length());
}
return string1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment