REPLACE
Replaces part of a text string with a different text string.
Syntax
expression.REPLACE(arg1, arg2, arg3, arg4);
expression - A variable that represents a ApiWorksheetFunction class.
Parameters
| Name | Required/Optional | Data type | Default | Description |
|---|---|---|---|---|
| arg1 | Required | ApiRange | ApiName | string | The text where some characters will be replaced. | |
| arg2 | Required | ApiRange | ApiName | number | The position of the character in the original text that will be replaced with the new text. | |
| arg3 | Required | ApiRange | ApiName | number | The number of characters in the original text that will be replaced. | |
| arg4 | Required | ApiRange | ApiName | string | The text that will replace characters in the original text. |
Returns
string
Example
This example shows how to replace a part of a text string with a different text string.
- Code
- Result
// How to replace a substring with another one.
// Use a function to replace one part of a text with another one.
let worksheet = Api.GetActiveSheet();
let func = Api.WorksheetFunction;
worksheet.GetRange("A1").SetValue(func.REPLACE("Online Office", 8, 6, "portal"));