Skip to content

Instantly share code, notes, and snippets.

@rozzy
Last active August 29, 2015 14:13
Show Gist options
  • Save rozzy/d3383dc4e2023de5e818 to your computer and use it in GitHub Desktop.
Save rozzy/d3383dc4e2023de5e818 to your computer and use it in GitHub Desktop.
void replace_string_in_place(std::string& subject, const std::string& search,
const std::string& replace) {
size_t pos = 0;
while ((pos = subject.find(search, pos)) != std::string::npos) {
subject.replace(pos, search.length(), replace);
pos += replace.length();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment