The gsub() function replaces all occurrences of the pattern within the source string.

result = gsub (pattern, replacement, sourcestring);
pattern Required. The regular expression pattern to search for.
replacement Required. The replacement string.
sourcestring Required. The source string to search for all occurrences of pattern.

The resulting string.

newstring = gsub("abc", "xyz", startingstring)

In this example, xyz replaces all occurrences of abc in startingstring.

For more information, please see sub.