Answer the question
In order to leave comments, you need to log in
Why doesn't std::string have a human replace?
Subject.
I'm aware that there's a replace that takes a bunch of indexes, and the code looks like this:
std::string Text = "source";
std::string ToReplace = "so";
std::string ReplaceWith = "11";
Text.replace(Text.find(ToReplace),ToReplace.length(),ReplaceWith);
Answer the question
In order to leave comments, you need to log in
There is such a replase!
std::string str = "string test";
std::replace(str.begin(), str.end(), 's', 'd');
#include <regex>
#include <string>
#include <iostream>
using namespace std;
int main()
{
string t = "asd asd asd";
t = regex_replace(t, regex("asd"), "sdf");
cout << t;
return 0;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question