cppstring GTextUtils::StringReplace(cppstring sBase, // string to search const cppstring &sSearchFor, // substring to search for (to be replaced) const cppstring &sReplaceWith) // string to replace sSearchFor with { // RETURN sBase with all instances of sSearchFor replaced by sReplaceWith if (sBase.empty() || sSearchFor.empty()) return sBase; int nStart = 0; while (sBase.find(sSearchFor, nStart) != cppstring::npos) { nStart = sBase.find(sSearchFor, nStart); int nEnd = sSearchFor.length(); sBase.replace(nStart, nEnd, sReplaceWith); nStart += sReplaceWith.length(); } return sBase; }