Replaces every occurrence of one substring with a different substring.

The Replace() function has three parameters:

  • sourceString (string): Required. The string to search.
  • searchSubstring (string): Required. The string to locate in sourceString.
  • replacementSubstring (string): Required. The string to replace searchSubstring with.

This example uses the RegExMatch() function to identify a piece of text (in this case, the names of the seasons) in a source string. It then uses the Replace() function to replace the name of the season in the source string with the current season.

The example returns the promotional message with the string "winter" replaced with "spring."