// 替换字符串中特征字符串为指定字符串
void GameOther::StrReplaceKeyWords(std::string &sSrc)
{
std::vector<std::string> maskStrVector;
maskStrVector.push_back("钓鱼岛");
maskStrVector.push_back("尖阁列岛");
for (int i = 0; i < maskStrVector.size(); i++)
{
string_replace(sSrc, maskStrVector.at(i), "***");
}
}
void GameOther::string_replace(string&s1,const string&old_str,const string&new_str)
{
string::size_type pos=0;
string::size_type a=old_str.size();
string::size_type b=new_str.size();
while((pos=s1.find(old_str,pos))!=string::npos)
{
s1.replace(pos,a,new_str);
pos+=b;
}
}