Text.Split

From Xojo Documentation

Method

Text.Split() As Text()

Supported for all project types and targets.

Returns an array of the characters in the Text.


Method

Text.Split(separator as Text, Optional compareOptions As Integer = 0, Optional locale As Xojo.Core.Locale = Nil) As Text()

Supported for all project types and targets.

Returns an array of the portions of the Text that are delimited by separator. If separator is the same as the text, an empty array is returned. If the text does not contain separator, an array containing only the original text value is returned.

Parameters

Parameter Description
separator The separator value used to split the text.
compareOptions (Optional) Comparison options. Use constant CompareCaseSensitive for case-sensitive comparisons.
locale (Optional) The locale to use for comparisons. By default an invariant locale (not dependent on the system settings) is used.

Notes

By default this performs a case-insensitive comparison. 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.

Split provides equivalent functionality to String.NthField.

Exceptions

Sample Code

Split the text into "Hello" and "World":

Dim t As Text = "Hello World"

Dim words() As Text
words = t.Split(" ")

Splits the text into an array with one element for each character:

Dim t As Text = "Hello, World!"

Dim chars() As Text
chars = t.Split