LOTUSSCRIPT LANGUAGE


Replace function
Example

Replaces specific words or phrases in a string with new words or phrases that you specify.

Note This function is new with Domino Release 6.

Syntax

Replace(sourceArray, findArray, replacementArray [, start [, count [, compMethod]]])

Elements

sourceArray


findArray
replacementArray
start
count
compMethod
Return value

Replace returns an Array of type String that contains sourceArray, where any values in replaceArray have been replaced by the corresponding values in replacementArray.

Usage

Replace searches the String in sourceArray for the String in replaceArray. If a match is found, the substring is replaced with a corresponding substring from replacementArray. Each String in replaceArray is scanned against each String in sourceArray as modified by prior substitutions. Replace is case sensitive.

If no matches are found, then a copy of sourceArray is returned.

If more strings are specified in replaceArray than in replacementArray, the extra strings in replaceArray are replaced with the last string in replacementArray. Extra strings in replacementArray are ignored.

For example:


would return: ["a b c"]

First, Replace substitutes "1" for "first" (the first String in replacementArray replaces the first string in replaceArray):


Then Replace substitutes "2" for "second":
Then "a" for "1" (since the first replacement was "1" for "first"):
Then "3" for "third":
"b" for "2":
And finally, "c" for "3":
If sourceArray, replaceArray, or replacementArray is not either a String, or an Array of type String, then a run-time type mismatch error is thrown.

Language cross-reference

@Replace function in formula language

EditFind @command in formula language

Example
See Also