+ while ( this->c_str()[dwPos] != wxT('\0') )
+ {
+ //DO NOT USE STRSTR HERE
+ //this string can contain embedded null characters,
+ //so strstr will function incorrectly
+ dwPos = find(szOld, dwPos);
+ if ( dwPos == npos )
+ break; // exit the loop
+ else
+ {
+ //replace this occurance of the old string with the new one
+ replace(dwPos, uiOldLen, szNew, uiNewLen);
+
+ //move up pos past the old string
+ dwPos += uiOldLen;
+
+ //increase replace count
+ ++uiCount;
+
+ // stop now?
+ if ( !bReplaceAll )
+ break; // exit the loop
+ }