Link Search Menu Expand Document

replace

Explanation Deletes the specified length from the specified position in the string and inserts the replacement string at that position.
Call format var s = replace( string, position, length, replacement string [, processing unit ] )
Return value Replaced string
Arguments String string Original character string
Integer position Position to operate in the character string
Integer length Length to delete
String replacement string String to replace
Integer processing unit 0: Treat as one character without distinguishing between half-width and full-width
1: Half-width characters are treated as one character, and full-width characters are treated as two characters. If omitted, half-width and full-width characters will not be distinguished.
*AI does not distinguish between half-width and full-width characters regardless of the argument*
Exception None
Example of use
var s = "I have a book. I have a pen.";
s = replace(s, 9, 4, "pencil");
s = replace(s, 0, 1, "You");
print(s, "\n");
Related item