ReplaceAll

From Xojo Documentation

Method

Replaces all occurrences of a string with another string.

Syntax

result=ReplaceAll(sourceString, oldString, newString)
OR
result=stringVariable.ReplaceAll(oldString, newString) Introduced 5.0

Part Type Description
result String A copy of sourceString with any changes made by the ReplaceAll function.
sourceString String The original string.
oldString String The characters to be replaced.
newString String The replacement characters.
stringVariable String A String variable containing the source string.

Notes

The ReplaceAll function replaces all occurrences of oldString in sourceString with newString. ReplaceAll is case-insensitive.

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

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

Examples

Below are some examples that show the results of the ReplaceAll function

Dim result As String
result = ReplaceAll("xyxyxy", "x", "z") // returns "zyzyzy"
result = ReplaceAll("The quick fox", " ", "") // returns "Thequickfox"
result = "The Quick Fox"
result = result.ReplaceAll(" ", ", ") // returns "The, Quick, Fox"

See Also

Replace, ReplaceAll, ReplaceAllB, ReplaceLineEndings functions.