c++替换string内所有符合条件的子串
std::size_t replaceAll(string& inout, string what, string with) { std::size_t count{}; for (std::string::size_type pos{}; inout.npos != (pos = inout.find(what.data(), pos, what.length())); pos += with.length(), ++count) { inout.replace(pos, what.length(), with.data(), with.length()); } return count; }
浙公网安备 33010602011771号