I am currently trying to write a class function that will replace every occurence of a word in a string with an other word , using C++11 lib.
void replace(std::string subject, std::string pattern, std::string replacement)
{
std::regex exp(pattern);
std::cout << std::regex_replace(subject, exp, replacement);
}
replace(std::string("Hello world"),std::string("world"),std::string("planet"));
returns nothing.
I guess that the problem is regular expression , but i have no idea and cannot find anywhere how to make a regexp matching an certain string using ECMAScript or any other availible in .
Does anyone know how to solve this problem ?