Text.Replace

From Xojo Documentation

Method

Text.Replace(find As Text, replace As Text, Optional compareOptions As Integer = 0, Optional locale As Xojo.Core.Locale = Nil) As Text

Supported for all project types and targets.

Creates a new value by replacing the first instances of the find parameter’s value with the replacement parameter’s value. If the input does not contain the requested value, nothing is replaced and the input is returned.

Parameters

Value Description
find The text to find.
replace The text to replace.
options (Optional) Use CompareCaseSensitive constant to have case-sensitive comparisons.
locale (Optional) Used to specify a Xojo.Core.Locale to use for the comparison.

Notes

By default this performs a case-insensitive comparison search. To do a case-sensitive comparison, supply the CompareCaseSensitive constant to the compareOptions parameter.

By default comparisons are done in an invariant locale (i.e. not dependent on the user's preferences). The locale parameter can be used to specify an explicit locale to do comparisons in.

Exceptions

Sample Code

Replace "World" with "Mars":

Dim t As Text = "Hello, World!"

Dim newText As Text
newText = t.Replace("World", "Mars") // newText = "Hello, Mars!"