How to replace all occurrences of a word in string in Groovy

1 Answer

0 votes
String s = "Groovy Java PHP Java C C++ C++ Java"

s = s.replaceAll("Java", "Python")

println(s)
      



/*
run:

Groovy Python PHP Python C C++ C++ Python

*/

 



answered Sep 30, 2020 by avibootz

Related questions

1 answer 367 views
2 answers 211 views
1 answer 150 views
1 answer 266 views
1 answer 175 views
...