How to remove all the whitespaces from a string in Kotlin? August 3, 2023 by Tarik Try var str = "This is an example text".filter { !it.isWhitespace() }