replace

fun replace(start: Int, end: Int, text: String)(source)

replaces the characters from start to end, the end excluded, with text; the caret goes after it