Skip to content

Instantly share code, notes, and snippets.

@tyabu12
Created February 25, 2015 10:59
Show Gist options
  • Save tyabu12/0d0f9fc4ee415ba19276 to your computer and use it in GitHub Desktop.
Save tyabu12/0d0f9fc4ee415ba19276 to your computer and use it in GitHub Desktop.
void replace(std::string& s, const std::string& from, const std::string& to)
{
std::size_t p1 = 0, p2;
while ((p2 = s.find(from, p1)) != s.npos) {
s.replace(p2, from.size(), to);
p1 = p2;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment