How can I easily replace characters in a std::string with another character?
Basically what I'd like is something like gsub (an addition to the string class in GNU's C++ class library). But I'm stuck on the Windows platform, and strongly encouraged to use the standard libraries as far as possible.
First I tried using string::iterator and indexing, but got terribly long errors when doing that.
Now my working solution is something like
- Convert it to a C-string (string::copy)
- Iterate over C-string, replacing characters
- Stick the C-string back into the C++-string
Is there an easier way?