How to remove all instances of the pattern from a string?
string str = "red tuna, blue tuna, black tuna, one tuna";
string pattern = "tuna";
How to remove all instances of the pattern from a string?
string str = "red tuna, blue tuna, black tuna, one tuna";
string pattern = "tuna";
This is a basic question and you'd better take a look at the string capabilities in the standard library.
Classic solution
Example
RegEx solution
Since C++11 you have another solution (thanks Joachim for reminding me of this) based on regular expressions
Example
Removes all instances of the pattern from a string,
Try something like:
From Replace part of a string with another string