Difference between revisions of "Split"

From Xojo Documentation

m (Text replacement - "{{Deprecated|" to "{{DeprecatedItem|")
(See Also)
Line 46: Line 46:
==See Also==
==See Also==
[[String]] data type; [[Var]] statement; [[Array]], [[String.Join]], [[Arrays]] concept
[[String]] data type; [[Var]] statement; [[Array]], [[Join]], [[Arrays]] concept

Latest revision as of 21:18, 18 January 2021


String.Split(delimiter As String) As String()

Supported for all project types and targets.

Creates a one-dimensional array from the String.


result = source.Split([delimiter])

Part Type Description
result String array Array resulting from breaking source into elements using delimiter as the field delimiter.
source String Source string to be parsed into an array.
delimiter String Optional field delimiter used to parse Source into array elements. If delimiter is omitted, then a space is used as the delimiter.


Use the Split function to create a new String array from a list of elements (or fields) that are separated by a delimiter. If the optional parameter, delimiter, is not passed, a single space is assumed as the delimiter. If the delimiter is an empty string, the source string is split into characters.

Sample Code

The section of code specifies the comma delimiter and the second uses the default delimiter. They place each field into an array element, producing a three-element array. The last code section parses the string into individual characters.

Var anArray() As String
Var s As String
s = "Adam,Aardvark,Accountant"
anArray = s.Split(",") // produces 3-element array
anArray = s.Split("") // produces array of individual characters

See Also

String data type; Var statement; Array, Join, Arrays concept