From Xojo Documentation


Replaces the first occurrence of a string with another string.


result=sourceVariable.Replace(oldString, newString)

Part Type Description
result String A copy of sourceVariable with any changes made by the Replace function.
sourceVariable String The original string.
oldString String The characters to be replaced.
newString String The replacement characters.


Replaces the first occurrence of oldString in sourceString with newString. Replace is case-insensitive.

If newString is an empty string (""), the Replace function deletes the first occurrence of the oldString in the sourceString.

If oldString is an empty string (""), the Replace function returns an unchanged copy of the sourceString.


Below are some examples that show the results of the Replace function:

Var result As String
Var source As String = "the quick fox"
result = source.Replace("fox", "rabbit") // returns "The quick rabbit"
result = source.Replace("f", "b") // returns "The quick box"
result = source.Replace("quick ", "") // returns "The fox"

See Also

ReplaceAll, ReplaceLineEndings functions.