Xbasic

split Function

Syntax

v split(string as C, delimiter as C, array as P)

Arguments

stringCharacter

The string to split into multiple substrings.

delimiterCharacter

The character used to split the string. If an empty string ("") is specified, the array contains one entry, the original string.

arrayPointer

The array to populate. Any values in the array will be overwritten.

Description

Splits a character string into an array of substrings.

Discussion

The split() function splits a string into one or more substrings and stores them in an array.

Example

dim str as C = "Life is trying things to see if they work."
dim strArray[0] as C

split(str, " ", strArray)
? strArray
= [1] = "Life"
[2] = "is"
[3] = "trying"
[4] = "things"
[5] = "to"
[6] = "see"
[7] = "if"
[8] = "they"
[9] = "work."

split(str, "i", strArray)
? strArray
= [1] = "L"
[2] = "fe "
[3] = "s try"
[4] = "ng th"
[5] = "ngs to see "
[6] = "f they work."

See Also