How to replace multiple characters in a string with other characters using Kotlin

1 Answer

0 votes
fun main() {
    var s = "Kotlin- prog****ra-mming! la!ng-uage!"
    
    s = s.replace("!", " ")
        .replace("*", "")
        .replace("a", "A")
        .replace("-", "+")
    
    println(s)
}



/*
run:
  
Kotlin+ progrA+mming  lA ng+uAge 
  
*/

 



answered Oct 21, 2024 by avibootz
...