This function replaces all substrings matching the given regular expression with a given replacement.
replaceAll(text, regex, replacement) #Output: Text
If you want to replace only the first matching occurrence, have a look at the replaceFirst() function.
replaceFirst("Hello World", "l", "_") | replaceAll("Hello World", "l", "_") |
---|---|
"He_lo World" | "He__o World" |
If you don't want to use a regular expression, have a look at the findReplaceAll() function.