takeLastWhile

Returns a subsequence of this char sequence containing last characters that satisfy the given predicate.

inline fun CharSequence.takeLastWhile(predicate: (Char) -> Boolean): CharSequence(source)
fun main() {
    val text = "abc123def456"
    val lastDigits = text.takeLastWhile { it.isDigit() }
    println(lastDigits)  // prints "456"
}

Source