ee.String.replace

Returns a new string with some or all matches of a pattern replaced.
UsageReturns
String.replace(regex, replacement, flags)String
ArgumentTypeDetails
this: inputStringThe string in which to search.
regexStringThe regular expression to match.
replacementStringThe string that replaces the matched substring.
flagsString, default: ""A string specifying a combination of regular expression flags, specifically one or more of: 'g' (global match) or 'i' (ignore case)

Examples

Code Editor (JavaScript)

print(ee.String('abc-abc').replace('abc', 'X'));  // X-abc
print(ee.String('abc-abc').replace('abc', 'X', 'g'));  // X-X
print(ee.String('abc-abc').replace('abc', '', 'g'));  // -
print(ee.String('aBc-Abc').replace('abc', 'Z', 'i'));  // Z-Abc
print(ee.String('aBc-Abc').replace('abc', 'Z', 'ig'));  // Z-Z