src/Generic/common/LocatedString.cpp
/**
 * All the offsets for any new text are set to the offset of the
 * character immediately to the left of the replaced text, or
 * immediately to the right if the text is replaced at the
 * beginning of the string.
 *
 * For example:
 *
 * <pre>    ["_one_two_", {100,101,102,103,104,105,106,107,108}].replace("_", " ")
 *    =>
 *    [" one two ", {101,101,102,103,103,105,106,107,107}]</pre>
 *
 * @param find the text to replace.
 * @param repl the text to replace it with.
 */
All the offsets for any new text are set to the offset of the
character immediately to the left of the replaced text, or
immediately to the right if the text is replaced at the
beginning of the string.

For example.



@param find the text to replace.
@param repl the text to replace it with.
All the offsets for any new text are set to the offset of the character immediately to the left of the replaced text or immediately to the right if the text is replaced at the beginning of the string . For example . @param find the text to replace . @param repl the text to replace it with .
void LocatedString::replace(const wchar_t *find, const wchar_t *repl) {
	int find_len = static_cast<int>(wcslen(find));
	int repl_len = static_cast<int>(wcslen(repl));
	int start = 0;
	while (start < length()) {
		int pos = indexOf(find, start);
		if (pos == -1)
			return;
		replace(pos, find_len, repl);
		start = pos + repl_len;
	}
}
void LocatedString :: replace ( const wchar_t * find , const wchar_t * repl ) { int find_len = static_cast < int > ( wcslen ( find ) ) ; int repl_len = static_cast < int > ( wcslen ( repl ) ) ; int start = 0 ; while ( start < length ( ) ) { int pos = indexOf ( find , start ) ; if ( pos == -1 ) return ; replace ( pos , find_len , repl ) ; start = pos + repl_len ; } }
All the offsets for any new text are set to the offset of the
 character immediately to the left of the replaced text, or
 immediately to the right if the text is replaced at the
 beginning of the string.
All the offsets for any new text are set to the offset of the character immediately to the left of the replaced text or immediately to the right if the text is replaced at the beginning of the string .