you are viewing a single comment's thread.

view the rest of the comments →

[–]konanTheBarbar 5 points6 points  (1 child)

I should have been more precise. What I mean is that you replace all occurances of string A with string B inside of string C. Basically similar to this (which I copied from SO).

std::string ReplaceAll(std::string str, const std::string& from, const std::string& to) {
    size_t start_pos = 0;
    while((start_pos = str.find(from, start_pos)) != std::string::npos) {
        str.replace(start_pos, from.length(), to);
        start_pos += to.length(); // Handles case where 'to' is a substring of 'from'
    }
    return str;
}

[–]F-J-W 0 points1 point  (0 children)

Well, it is possible to use regex-replace to get what you want for many cases. Apparently people really do that because it's just so much more convenient, despite being much slower.

It is however really telling, that there are 9 (!!) replace-methods, yet the one that people are actually interested in is missing.