### Replace

Basic and Crystal syntax.

##### Overloads

- Replace (inputString, findString, replaceString)
- Replace (inputString, findString, replaceString, startPosition)
- Replace (inputString, findString, replaceString, startPosition, count)
- Replace (inputString, findString, replaceString, startPosition, count, compare)

##### Arguments

- inputString is a String containing substring to replace.
- findString is a substring being searched for.
- replaceString is the replacement substring.
- startPosition is an optional Number indicating the position within inputString where substring search is to begin. If omitted, 1 is assumed.
- count is an optional Number of substring substitutions to perform. If omitted, the default value is -1, which means make all possible substitutions.
- compare is an optional Number indicating the kind of comparison to use when evaluating substrings:
  - Performs a comparison that is case-sensitive
  - Performs a comparison that is case-insensitive

    If omitted, a case-sensitive comparison is performed.

##### Returns

String value.

##### Action

Replace 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 where in the String to begin replacing, and return a String starting from that position.

##### Typical use

To systematically replace in a String one substring with another.

##### Examples

The following examples are applicable to both Basic and Crystal syntax. They assume that inputString is the text String "Monday is my day off. Can we meet next Monday?".

`Replace (inputString, "Monday", "Wednesday")`

Returns "Wednesday is my day off. Can we meet next Wednesday?".

`Replace (inputString, "Monday", "Wednesday", 23)`

Returns "Can we meet next Wednesday?" The replacement begins at the 23rd character from the beginning of the original inputString. The returned string is this portion of the string with the substitutions made.

`Replace (inputString, "Monday", "Wednesday", 1, 1)`

Returns "Wednesday is my day off. Can we meet next Monday?" There is only 1 replacement beginning at the 1st character from the beginning of the original inputString. The returned string is thus the original string with the single substitution made.

`Replace (inputString, "monday", "Wednesday", 1, -1, 0)`

Returns the same inputString with no replacements since no match was found for "monday" with a case-sensitive comparison.

`Replace (inputString, "monday", "Wednesday", 1, -1, 1)`

Returns the inputString with both occurrences of "Monday" replaced by "Wednesday". That is, "Wednesday is my day off. Can we meet next Wednesday?".

##### Comments

- This function is designed to work like the Visual Basic function of the same name.
- The returned value of the Replace function is a String, with the specified substring replacements made, that begins at the position specified by startPosition and ends at the end of the inputString string. It is not a copy of the original string from start to finish.

Seagate Software, Inc. http://www.seagatesoftware.com Please send comments to: techpubs@seagatesoftware.com