findLast

inline fun CharSequence.findLast(predicate: (Char) -> Boolean): Char?(source)

Returns the last character matching the given predicate, or null if no such character was found.

Since Kotlin

1.0

Samples

import java.util.Locale
import kotlin.test.*

fun main() { 
   //sampleStart 
   val text = "a1b2c3d4e5"

println(text.findLast { it.isLetter() }) // e
println(text.findLast { it.isUpperCase() }) // null
println("".findLast { it.isLowerCase() }) // null 
   //sampleEnd
}