Link Search Menu Expand Document

SPLIT_PART

Divides a string based on a specified delimiter into an array of substrings. The string in the specified index is returned, with 1 being the first index. If the string separator is empty, the string is returned at index 1.

Syntax

SPLIT_PART(<string>, <delimiter>, <index>)

Please note that the order of the arguments is different than the SPLIT function.

Parameters

Parameter Description Supported input types
<string> An expression evaluating to a string to be split. TEXT
<delimiter> Any character or substring within <string>. If <delimiter> is an empty string '', the <string> will be returned at index 1. TEXT
<index> The index from which to return the substring. INTEGER

Return Type

TEXT

Examples

SELECT
	SPLIT_PART('hello#world','#',1) AS res;

Returns: hello

SELECT
	SPLIT_PART('this|is|my|test', '|', 4 ) AS res;

Returns: test

SELECT
	SPLIT_PART('hello world', '', 1 ) AS res;

Returns: hello world

SELECT
	SPLIT_PART('hello world', '', 7 ) AS res;

Returns: ``