在C++中是否可以用另一个字符串替换字符串的一部分?
基本上,我想这样做:
QString string("hello $name");
string.replace("$name", "Somename");
Run Code Online (Sandbox Code Playgroud)
但我想使用标准C++库.
我试图遵循这个答案:https://stackoverflow.com/a/32435076/5484426,但对于std :: wstring.到目前为止,我有这个:
std::wstring str = L"hello hi hello hi hello hi";
std::wregex remove = L"hi";
Run Code Online (Sandbox Code Playgroud)
现在我想这样做:regex_replace(str,remove,"");
虽然看起来regex_replace不适用于wstring.如何删除此字符串的所有实例?