zt
val values = match.groupValues.drop(1) // ["kotlin slack"] var newResponse = filter.response!! // "hi $1" values.forEachIndexed { index, value -> newResponse = filter.response!!.replace("\$$index", value) } // newResponse = "hi kotlin slack"
$0
$1
$2
ephemient
repsonse.replace("\$([0-9])".toRegex()) { match -> values[match.group(1).toInt()] }
Michael de Kaste
"hi $3, $1 and $2" .replace("""\$(\d+)""".toRegex()) { "%${it.groupValues[1]}\$s" } .format("tom", "alice", "bob") // hi bob, tom and alice
%
A modern programming language that makes developers happier.