replaceing characters in a string
-
Hi, can ne1 help if i had a string, mystring = "0933221212" and i wanted to replace the first two characters "09" with say "012" so i was left with "01233221212" whats the best way of doing this thanks loads si
-
CString mystring = "0933221212"; mystring.Replace( "09", "012" ); // Afterall, I realized that even my comment lines have bugs When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
-
thanks for the quick reply the problem with what you sent me, is that it will replace all occurrances of 09 with 012, i need it to replace only one occurance of 09 which will always be the first two characters thanks si
-
thanks for the quick reply the problem with what you sent me, is that it will replace all occurrances of 09 with 012, i need it to replace only one occurance of 09 which will always be the first two characters thanks si
if myString.Right(2)=="09" { myString.Delete(0, 2); myString.Insert(0, "123"); } MS
-
if myString.Right(2)=="09" { myString.Delete(0, 2); myString.Insert(0, "123"); } MS
-
Hi, can ne1 help if i had a string, mystring = "0933221212" and i wanted to replace the first two characters "09" with say "012" so i was left with "01233221212" whats the best way of doing this thanks loads si
If you want to replace the first two characters, then do this:
mystring = _T("012") + mystring.Mid(2);
Hope this helps,
Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"