#### ReplaceString

##### ReplaceString(inString, searchString, replaceString, startPosition, count, compare)

Returns a String in which a specified substring has been replaced with another substring a specified number of times. As an option, you can also specify a location in the string where the replacing process will begin from (returns a string starting from that position). This function is typically used in a string to systematically replace one substring with another.

Overloads

- ReplaceString(inString, searchString, replaceString)
- ReplaceString(inString, searchString, replaceString, startPosition)
- ReplaceString(inString, searchString, replaceString, startPosition, count)
- ReplaceString(inString, searchString, replaceString, startPosition, count, compare)

Parameters

- inString - A String containing substring to replace.
- searchString - A substring being searched for.
- replaceString - The replacement substring.
- startPosition - An optional Number indicating the position within inString where the substring search is to begin from. If omitted, 1 will be used.
- count - An optional Number of substring substitutions to be performed. If omitted, the default value is -1, which means make all possible substitutions.
- compare - An optional Number indicating the kind of comparison to use when evaluating substrings:
  - 0 performs a comparison that is case-sensitive
  - 1 performs a comparison that is case-insensitive
  - If omitted, a case-sensitive comparison will be performed

Return value

String value.

Examples

Assume that inStrings = "abc Abc abcdfg asdfabc sdfdfd", searchString = "abc", replaceString = "ABC".

- `ReplaceString(inStrings, searchString, replaceString)` - Returns "ABC Abc ABCdfg asdfABC sdfdfd".
- `ReplaceString(inStrings, searchString, replaceString, 5)` - Returns "abc Abc ABC dfg asdfABC sdfdfd".
- `ReplaceString(inStrings, searchString, replaceString, 0)` - Returns "ABC Abc ABCdfg asdfABC sdfdfd".
- `ReplaceString(inStrings, searchString, replaceString, 0, 0)` - Returns "abc Abc abcdfg asdfabc sdfdfd".
- `ReplaceString(inStrings, searchString, replaceString, 0, 1)` - Returns "ABC Abc abcdfg asdfabc sdfdfd".
- `ReplaceString(inStrings, searchString, replaceString, 0, -1,1)` - Returns "ABC ABC ABCdfg asdfABC sdfdfd".
- `ReplaceString(inStrings, searchString, replaceString, 0, -1, 0)` - Returns "ABC Abc ABCdfg asdfABC sdfdfd".

Note: The return value of the replace function is a String, with the specified substring replacements made, beginning at the position specified by startPosition, and endings at the end of the inString string. It is not a start to finish copy of the original string.