//将str中的oldstr替换为newstr
void replace(string &str,string oldstr,string newstr)
{
int pos=string::npos;
int start_index=0;
int old_str_len=oldstr.size(),new_str_len=new_str_len=newstr.size();
while((pos=str.find(oldstr,start_index))!=string::npos)
{
str.replace(pos,old_str_len,newstr);
start_index=pos+new_str_len;
}
}