STRTOK
functionsupportedCore SQL functionsTokenizes a given string and returns the requested part.
Syntax
supportedpartialnot supportednot scored
STRTOK(<string> [,<delimiter>] [,<partNumber>])
Parameters
| Name | Required | Description |
|---|---|---|
string | required | Text to be tokenized. |
delimiter | optional | Text representing the set of delimiters to tokenize on. Each character in the delimiter string is a separate delimiter. For example, if the delimiter is '@.', then both '@' and '.' are treated as delimiters. This behavior differs from SPLIT_PART, which treats the entire delimiter as a single delimiter string. 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. Default: A single space character |
partNumber | optional | Requested token, which is 1-based so that the first token is token number 1, not token number 0. If the token number is out of range, then NULL is returned. Default: 1 |
Returns
The data type of the returned value is VARCHAR. If the requested part doesn’t exist or any argument is NULL, then NULL is returned.
Usage notes
- Similar to Linux strtok(), STRTOK never returns an empty string as a token. This behavior differs from SPLIT_PART, which can return empty strings as parts when the input string starts or ends with the delimiter, or when there are consecutive delimiters.