Developer Documentation Library > UNICOM Intelligence Function Library > Miscellaneous functions > Replace
 
Replace
Replaces part of a text or categorical value with another value of the same type.
Syntax
Replace(<value>, <key>, <replacement> [, <start> [, <count> [, <ignore_case>]]])
Parameters
<value>
Type: None
Variant value of type Text or Categorical.
<key>
Type: None
Variant value to look for in <value>, of the same type as <value>.
<replacement>
Type: None
Variant value with which to replace Key, of the same type as <value>.
<start>
Type: Long
(Optional.) Position in <value> (starting from 0), from which to start searching for <key>. If omitted or less than 0, searching starts at the start of <value>.
<count>
Type: Long
(Optional.) Maximum number of replacements to make. If omitted or less than 0, all possible replacements are made.
<ignore_case>
Type: Boolean
(Optional.) Whether to do case-insensitive comparison for <key>. The default value is False.
(return)
Type: None
Copy of <value> with Key replaced with <replacement>.
Notes
If <value> is of type Text, <key> and <replacement> are converted to text values, unless they are already text values or NULL. If <value> is of type Categorical, <key> and <replacement> are converted to categorical values, unless they are already categorical values or NULL. An error occurs if <key> or <replacement> cannot be converted to the required type.
If <value> is NULL, the return value is NULL. If <key> is NULL, no replacements are made. If <replacement> is NULL, occurrences of <key> are removed instead of being replaced. If <value> is of any other type, an error occurs.
Examples
The following mrScriptBasic example shows the use of the Replace function to replace all the hyphens in a text variable with spaces.
strVal = strVal.Replace("-", " ")
See also
Miscellaneous functions