filterTo

Appends all characters matching the given predicate to the given destination.

@IgnorableReturnValueinline fun <C : Appendable> CharSequence.filterTo(destination: C, predicate: (Char) -> Boolean): C(source)
fun main() {
    val source = "a1b2c3"
    val result = StringBuilder()
    source.filterTo(result) { it.isDigit() }
    println(result.toString()) // prints 123
}

Source