Key String Functions: trim, split, replace, contains
Apply the most useful String extension functions in real scenarios.
Kotlin's Rich String API
Kotlin extends Java's String with dozens of extension functions. You'll use trim, split, replace, and contains constantly.
trim, trimStart, trimEnd
Remove whitespace (or specific characters) from the edges of a string.
val s = " hello "
println(s.trim()) // "hello"
println(s.trimStart()) // "hello "
println(s.trimEnd()) // " hello"
println("##hi##".trim('#')) // "hi"All lessons in this course
- String Basics: Literals, Escape Sequences & Length
- String Templates: $variable and ${expression}
- Raw Strings and Triple Quotes
- Key String Functions: trim, split, replace, contains