I apologize if this already has been answered but I didn't manage to find a solution on exactly this. I want to find all occurrences of a specific substring in a string and then replace those substrings with something else, for example:
int main(){
// Variabeldeklaration
string str = "elephant elephant duck duck elephant";
if (/* string contains "elephant" */){
// replace_all "elephant" , "gorilla";
}
// Now str = "gorilla gorilla duck duck gorilla";
system("PAUSE");
return 0;
}
I know it's possible to replace all char found in a string but I want to be able to replace more than one char. How do I do this?