相关疑难解决方法(0)

用另一个字符串替换字符串的一部分

在C++中是否可以用另一个字符串替换字符串的一部分?

基本上,我想这样做:

QString string("hello $name");
string.replace("$name", "Somename");
Run Code Online (Sandbox Code Playgroud)

但我想使用标准C++库.

c++ string replace substring std

171
推荐指数
8
解决办法
27万
查看次数

如何使用正则表达式删除std :: wstring中特定短语的所有实例?

我试图遵循这个答案: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.如何删除此字符串的所有实例?

c++ regex string replace std

0
推荐指数
1
解决办法
279
查看次数

标签 统计

c++ ×2

replace ×2

std ×2

string ×2

regex ×1

substring ×1