regexReplace
Syntax
regexReplace(str, pattern, replacement, [offset])
Arguments
str is a string scalar or vector.
pattern is an ordinary string scalar or a regular expression pattern to be searched in str.
replacement is a string scalar. It is used to replace pattern in str.
offset is a positive integer with default value of 0. This optional argument is the starting position in str to conduct the search and replace operation. The first character in str corresponds to positive 0.
Details
Search in a string for another string or a regular expression pattern and replace every occurrence of the matched string or pattern with the specified string.
Examples
regexReplace("IBM FB IBM AMZN", `IBM, `GOOG);
// output
GOOG FB GOOG AMZN
regexReplace("IBM FB IBM AMZN", `IBM, `GOOG, 5);
// output
IBM FB GOOG AMZN
regexReplace("IBM FB IBM AMZN", `IBM, `GOOG, 10);
// output
IBM FB IBM AMZN