How to remove all occurrences of word from a string in Scala

1 Answer

0 votes
object RemoveAllOccurrencesOfWordFromString_Scala extends App {
  var s = "scala c# rust java c c++ java java golang python"
  val remove = "java"
 
  s = s.replaceAll(remove, "")
 
  println(s)
}

   
   
/*
run:
   
scala c# rust  c c++   golang python
   
*/

 



answered Oct 13, 2024 by avibootz
edited Oct 14, 2024 by avibootz
...