int ReplaceAll( std::string* str, const std::string& pattern, const std::string& newpat )
{
int count = 0;
const size_t nsize = newpat.size();
const size_t psize = pattern.size();
for ( size_t pos = str->find( pattern, 0 ); pos != std::string::npos; pos = str->find( pattern, pos + nsize ) )
{
str->replace( pos, psize, newpat );
count++;
}
return count;
}
替换字符串
最新推荐文章于 2023-11-15 17:15:00 发布