SPLIT Function

Splits a string by a caller-specified separator and either returns the substrings as an array, or returns one specific substring.

Syntax

SPLIT(text, separator, [which-substring])

Parameters

Return Value

If which-substring is provided, then the specified substring is returned. If it is not provided, then an array of all the substrings is returned.

Example

PRINT SPLIT('AAA|BBB|CCC', '|', 1);  -- "BBB"
PRINT SPLIT('AAA|BBB|CCC', '|', 5); -- NULL
PRINT SPLIT('AAA|BBB|CCC', '|'); -- "[AAA, BBB, CCC]"