Description
Replaces a substring in variable with a specified string.
Syntax
variable [start, length] = expression
Parameters
The brackets operator has the following parameters when used for insertion. Use start and length to define the substring.
Parameter | Description |
---|---|
Start | A positive or negative integer.
|
Length | Number of characters to replace, beginning from start. Each space and character within the string is counted as a character position. Also, note that the value specified for length includes the character position specified by start. Note: Length can be negative, signifying reverse order. |
expression | Replaces the substring in variable that has been defined by the parameters start and length. If expression yields a string that is longer than the specified substring, the total string length of variable will increase. If expression yields a shorter string, then the total string length of variable decreases. In other words, the entire substring defined by start and length is replaced by whatever is the value of expression. |
Example
The following example The following example shows how to use the brackets operator for insertion.
* When LENGTH = 0. This yields "ABXXYYCDEF" string = "ABCDEF" string[-4,0] = "XXYY" /* When LENGTH = negative number, the reverse order: yields "A123EF" */ string = "ABCDEF" string[4,-3] = "123"