1. find i erase / find i replace
#include <iostream>
#include <string>
int main() {
std::string str = "babarybabbrybbabarybabbryb";
std::string word = "bbryb";
std::size_t pos;
while (pos = str.find(word), pos != std::string::npos) { // (pos = str.find(word)) != std::string::npos
str.erase(pos, word.size());
}
std::cout << str << "\n";
}
2. regex C++11
std::cout << std::regex_replace(str, std::regex(word), "") << '\n';
3. boost
boost::algorithm::replace_all(str, word, "");