Ereplace Function
Replaces one or more instances of a substring.
Syntax
Ereplace (string, substring, replacement [ ,number [ ,start] ] )
string is the string or expression.
substring is the substring you want to replace. If substring is an empty string, replacement is prefixed to expression.
replacement is the replacement substring. If replacement is an empty string, all occurrences of substring are removed.
number specifies the number of instances of substring to replace. To change all instances, use a value less than 1.
start specifies the first instance to replace. A value less than 1 defaults to 1.
Remarks
A null value for string returns a null value. If you use a null value for any other variable, a runtime error occurs.
Examples
The following example replaces all occurrences of one substring with another:
MyString = "AABBCCBBDDBB"
NewString = Ereplace(MyString, "BB", "xxx")
* The result is "AAxxxCCxxxDDxxx"
The following example replaces only the first two occurrences:
MyString = "AABBCCBBDDBB"
NewString = Ereplace(MyString, "BB", "xxx", 2, 1)
* The result is "AAxxxCCxxxDDBB"
The following example removes all occurrences of the substring:
MyString = "AABBCCBBDDBB"
NewString = Ereplace(MyString, "BB", "")
* The result is "AACCDD"