gsub

Description

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

Syntax

result = gsub (pattern, replacement, sourcestring);

Arguments

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.

Return Values

The resulting string.

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

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

For more information, see sub.