Skip to main content

REPLACEB

Replaces a set of characters, based on the number of characters and the start position specified, with a new set of characters and is intended for languages that use the double-byte character set (DBCS) like Japanese, Chinese, Korean etc.

Syntax

expression.REPLACEB(arg1, arg2, arg3, arg4);

expression - A variable that represents a ApiWorksheetFunction class.

Parameters

NameRequired/OptionalData typeDefaultDescription
arg1RequiredApiRange | ApiName | stringThe text where some characters will be replaced.
arg2RequiredApiRange | ApiName | numberThe position of the character in the original text that will be replaced with the new text.
arg3RequiredApiRange | ApiName | numberThe number of characters in the original text that will be replaced, based on bytes.
arg4RequiredApiRange | ApiName | stringThe text that will replace characters in the original text.

Returns

string

Example

Replace a portion of text by position and character count, supporting double-byte characters in a spreadsheet.

// How do I replace text by counting characters from the start in languages like Chinese or Japanese in a spreadsheet?

// Swap a substring using byte positions instead of character positions for multilingual text in a spreadsheet.

let worksheet = Api.GetActiveSheet();
let func = Api.WorksheetFunction;
worksheet.GetRange("A1").SetValue(func.REPLACEB("Online Office", 8, 6, "portal"));