Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

groovy
replaceall()
communitycreator

What is replaceAll() in groovy?

Sheza Naveed

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

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 replace text.

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

RELATED TAGS

groovy
replaceall()
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring