void replaceAll(std::string& str, const std::string& srcKey, const std::string& dstKey)
{
if (srcKey.empty()) {
return;
}
size_t idx = str.find(srcKey);
while (idx != std::string::npos) {
str.replace(idx, srcKey.length(), dstKey);
idx = str.find(srcKey, idx + dstKey.length());
}
}
替换字符串中的所有子字符串
最新推荐文章于 2023-08-02 18:03:51 发布