base.StringBuffer.replaceAt

Replace part of a string with another string.

Syntax

replaceAt(
   start INTEGER,
   length INTEGER,
   new STRING )
  1. start is position where the replacement starts.
  2. length is the number of characters to be replaced.
  3. new is the replacement string.

Usage

The replaceAt() method replaces part of the current string with another string.

The parameters are integers indicating the position at which the replacement should start, the number of characters to be replaced, and the replacement string.

The first position in the string is 1.

Important: When using byte length semantics, the position and length are expressed in bytes. When using char length semantics, the unit is characters. This is matters when using a multibyte locale such as UTF-8.

Example

CALL buf.append("abxxxxef")
CALL buf.replaceAt(3,4,"cd")
DISPLAY buf.toString() -- Shows abcdef