tokenize_part

Description

Tokenizes the input string using the delimiter and returns the requested part.

The delimiter is treated as a set of characters. Each character in the delimiter string is a delimiter. The default delimiter is “ “. If the delimiter is empty, and the string is empty, then the function returns NULL. If the delimiter is empty, and the string is non empty, then the whole string will be treated as one token. The part argument is 1-based and the default value is 1. If the part number is out of range, then NULL is returned.

Return type

string

Domain

This is a scalar function (calculates a single output value for a single input row.)

Categories

Usage

tokenize_part(value, [ delimiter ], [ part ])

Argument

Type

Optional

Repeatable

Restrictions

value

string

no

no

none

delimiter

string

yes

no

constant

part

int64

yes

no

none

Examples

tokenize_part("a b c d")

Returns the default part, tokenized by the default delimiter, which ends up with “a”.

tokenize_part("[email protected]", "@.")

Returns the default part of the input string tokenized by delimiter ‘@’ or ‘.’, which ends up being “hello”.

tokenize_part("[email protected]", "@.", 2)

Returns the second piece (one-based indexing) when tokenizing by delimiters ‘@’ and ‘.’, which ends up being “example”.