Archive: June 2026

Kotlin Kandy: Get Text Before Or After A Delimiter

Posted on by  
Hubert Klein Ikkink

Kotlin adds the substringBefore, substringBeforeLast, substringAfter and substringAfterLast extension functions to the String class. Instead of using indices to get a substring you can use a string or character value. The functions without Last use the first occurrence of the delimiter and the methods with Last use the last occurrence. If the delimiter is not found the original string is returned. You can supply a value that should be returned when the delimiter is not found.

Continue reading →

shadow-left