Strings In Depth15 / 17
Up next

substringBefore

fun main() {
    val s = "hello world"
    // everything before the first space
    println(s.substringBefore(" "))
    // a fallback when the separator is absent
    println("nospace".substringBefore(" ", "none"))
}
What you're solving

take text up to a separator