Replace

std::wstring Replace( const wstring& orignStr, const wstring& oldStr, const wstring& newStr ) 

size_t pos = 0; 
wstring tempStr = orignStr; 
wstring::size_type newStrLen = newStr.length(); 
wstring::size_type oldStrLen = oldStr.length(); 
while(true) 

pos = tempStr.find(oldStr, pos); 
if (pos == wstring::npos) break;
tempStr.replace(pos, oldStrLen, newStr);         
pos += newStrLen;
}
return tempStr; 
}

你可能感兴趣的:(Replace)