What is replaceAll() in groovy?
replaceAll() is a function in groovy that replaces all occurrences of a string with a specified string.
Syntax
void replaceAll(String text, String replace)
Parameters
-
text: the string that needs to be replaced. -
replace: the string which would replacetext.
Return value
This method returns the modified String.
Code
class Main {static void main(String[] args) {String text = "Hello Educative Hello";println(text.replaceAll("Hello","Edpresso"));}}
Output
Edpresso Educative Edpresso