Skip to content

Instantly share code, notes, and snippets.

@dima74
Last active May 30, 2017 20:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dima74/64a90035aeed0f5fc754279b03b8d313 to your computer and use it in GitHub Desktop.
Save dima74/64a90035aeed0f5fc754279b03b8d313 to your computer and use it in GitHub Desktop.
Функция, заменяющая все подстроки в строке. Понравилась? Поставь звёздочку!
void replaceAll(string &source, string search, string replace) {
size_t position = 0;
while ((position = source.find(search, position)) != string::npos) {
source.replace(position, search.length(), replace);
position += replace.length();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment