replace function

String replace(
  1. String string,
  2. Pattern pattern,
  3. String replacement
)

Replaces matches for pattern in string with replacement.

Implementation

String replace(String string, Pattern pattern, String replacement) {
  return string.replaceAll(pattern, replacement);
}