String.ReplaceAllBytes

From Xojo Documentation

Method

Replaces all occurrences of a string with another string.

Syntax

result=stringVariable.ReplaceAllBytes(oldString, newString)

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

Notes

The ReplaceAllBytes function replaces all occurrences of oldString in sourceString with newString. ReplaceAllBytes is case-sensitive because it treats the source string as a series of raw bytes.

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

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

ReplaceAllBytes is case-sensitive; it treats sourceString as a series of raw bytes. It should be used instead of ReplaceAll when the string represents a series of bytes or when your application will run in a one-byte character set (such as the US system) and you want case-sensitivity.

Examples

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

Var result As String
Var source As String = "xyxyxy"
result = source.ReplaceAllBytes("x", "z") // returns "zyzyzy"

source = "The quick fox"
result = source.ReplaceAllBytes(" ", "") // returns "Thequickfox"


source = "The Quick Fox"
result = source.ReplaceAllBytes(" ", ", ") // returns "The, Quick, Fox"

See Also

Replace, ReplaceAll, ReplaceLineEndings functions.