Split
Returns an array that contains substrings.
Use this function to parse strings that contain substrings separated by a character such as a comma (,). For example, the lines of an address are often separated by a comma.
Syntax
Split(<value> [, <delimiter> [, <count> ]])
Parameters
<value>
Type: Text
<delimiter>
Type: Text
(Optional.) Delimiter between substrings. The default value is a single space.
<count>
Type: Long
(Optional.) The maximum number of substrings to return. If omitted or less than zero, all substrings are returned.
(return)
Type: Categorical
An array containing the substrings from <value>.
Notes
If <value> is an empty string, the return value is an empty array. Otherwise, if Delimiter is an empty string or is not found in Val, the return value is an array containing one item, a copy of <value>. If the current data value is NULL, <value> is an empty string and the return value is an empty array.
The Split function returns a categorical value, making it impossible to assign elements of the returned array. The result from the Split function is not a real categorical value, because the elements of a categorical must be of type Long (int - VT_I4), not text. The parser treats the value as a categorical, but an error is returned when trying to pass the value into a function that expects a real categorical (ContainsAny for example).
Example
The following mrScriptBasic example returns the first line and the first two lines of an address that is stored in a single variable with the lines separated by commas. It also shows an example of using the function using the default parameters:
Dim Address, FirstLine, FirstTwoLines, Defaults
Address = "363 Park Road, Ashford, Kent"
FirstLine = Address.Split(",", 1) ' Returns {363 Park Road}
FirstTwoLines = Address.Split(",", 2) ' Returns {363 Park Road, Ashford}
Defaults = Address.Split() ' Returns {363,Park,Road,,Ashford,,Kent}
See also