splitParts
Description
Splits a string using a delimiter and return the token at the specified index. The index starts at 1, not 0.
Syntax
Like many functions in DataPrime, splitParts supports two notations, function and method. These interchangeable forms allow flexibility in how you structure expressions.
- Function notation
- Method notation
splitParts(value: string, delimiter: string, index: number): string
(value: string).splitParts(delimiter: string, index: number): string
Arguments
| Name | Type | Required | Description |
|---|---|---|---|
value | string | true | The string to split |
delimiter | string | true | The delimiter used to split the string |
index | number | true | The 1-based index of the token to return |
Example
Extract the domain from an email address
Consider the following document:
{
"email": "chris@coralogix.com"
}
Use splitParts to extract the domain in one step:
Example query
- Function notation
- Method notation
create domain from splitParts(email, '@', 2)
create domain from email.splitParts('@', 2)
Example output
{
"email": "chris@coralogix.com",
"domain": "coralogix.com"
}