Splits a string into sub-strings based on the specified delimiter. Sub-strings are stored in a new array and a handle to this array is returned. The returned array contains the exact number of split strings. You can use the ArrayCount function to determine the number of strings into which the source was split.
Consecutive delimiters are treated as a single delimiter. By default, leading and trailing white space is trimmed from sub-strings.
Syntax
StrSplit(STRING sSource, STRING sDelim, INT bNoTrim)
sSource
The source string to split.
sDelim
The string to use as a delimiter. If not specified, a comma (,) is used.
bNoTrim
Optional flag to disable the trimming of white space from sub-strings. Trimming will occur by default.
Return Value
Returns a handle to the array containing all sub-strings.
Example
STRING sNames = "Phil, Michael, Bradley"
STRING sName;
INT aNames
INT iItem = 0;
aNames = StrSplit(sNames, ",");
WHILE (sName <> "") DO
sName = ArrayGetString(aNames, iItem);
iItem = iItem + 1;
END
ArrayDestroy(aNames);
Related Functions
Published June 2018