CString::Replace int Replace( TCHAR chOld, TCHAR chNew );int Replace( LPCTSTR lpszOld, LPCTSTR lpszNew ); Example//First example, with old and new equal in length.CString strZap("C--"); int n = strZap.Replace('-', '+'); ASSERT(n == 2); ASSERT(strZap == "C++");//Second example, old and new are of different lengths.CString strBang("Everybody likes ice hockey"); n = strBang.Replace("hockey", "golf"); ASSERT(n == 1); n = strBang.Replace("likes", "plays"); ASSERT(n == 1); n = strBang.Replace("ice", NULL); ASSERT(n == 1); ASSERT(strBang == "Everybody plays golf");// note that you now have an extra space in your // sentence. To remove the extra space, include it // in the string to be replaced, i.e.,"ice ".
Your question is strange. If the string is just like you provide, I think it must be wrong. Because '\' is a escape char, so the string you provided has no '\'; escape char is used just in case of const string.
int Replace( TCHAR chOld, TCHAR chNew );int Replace( LPCTSTR lpszOld, LPCTSTR lpszNew );
Example//First example, with old and new equal in length.CString strZap("C--");
int n = strZap.Replace('-', '+');
ASSERT(n == 2);
ASSERT(strZap == "C++");//Second example, old and new are of different lengths.CString strBang("Everybody likes ice hockey");
n = strBang.Replace("hockey", "golf");
ASSERT(n == 1);
n = strBang.Replace("likes", "plays");
ASSERT(n == 1);
n = strBang.Replace("ice", NULL);
ASSERT(n == 1);
ASSERT(strBang == "Everybody plays golf");// note that you now have an extra space in your
// sentence. To remove the extra space, include it
// in the string to be replaced, i.e.,"ice ".