dropLastWhile
Returns a subsequence of this char sequence containing all characters except last characters that satisfy the given predicate.
inline fun CharSequence.dropLastWhile(predicate: (Char) -> Boolean): CharSequence(source)
fun main() {
val text = "Sample text!!!"
val trimmed = text.dropLastWhile { it == '!' }
println(trimmed) // Output: Sample text
}