How to remove punctuation from a string in Kotlin

1 Answer

0 votes
fun main() {
    var str = "Kotlin: is a cross-platform, statically typed ~!@#$%^&*() programm[i]ng language"

    str = str.replace(Regex("\\p{Punct}"), "")

    println(str)
}

 
 
/*
run:
   
Kotlin is a crossplatform statically typed  programming language
   
*/


 



answered Nov 11, 2024 by avibootz
...