Splits up a string into substrings depending on the given delimiters.
StringSplit ( "string", "delimiters" [, flag ] )
Parameters
| string | The string to evaluate. |
| delimiters | One or more characters to use as delimiters (case sensitive). |
| flag | [optional] Changes how the string split works, add mutliple flag values together if required: flag = 0 (default), each character in the delimiter string will mark where to split the string flag = 1, entire delimiter string is needed to mark the split flag = 2, disable the return the count in the first element - effectively makes the array 0-based (must use UBound() to get the size in this case). |
Return Value
Returns an array, by default the first element ($array[0]) contains the number of strings returned, the remaining elements ($array[1], $array[2], etc.) contain the delimited strings. If flag = 2 then the count is not return in the first element.
Remarks
If you use a blank string "" for the delimiters, each character will be returned as an element.
Related
StringInStr, StringLeft, StringLen, StringLower, StringMid, StringRight, StringTrimLeft, StringTrimRight, StringUpper
Example
$days = StringSplit("Sun,Mon,Tue,Wed,Thu,Fri,Sat", ",")
;$days[1] contains "Sun" ... $days[7] contains "Sat"
$text = "This\nline\ncontains\nC-style breaks."
$array = StringSplit($text, '\n', 1)