splitParts - Split and capture a token in one command
We often split string
values in order to capture some consistent parts. For example, we split chris@coralogix.com
on @
to capture the domain, coralogix.com
. splitParts
does two things in one. The first is it splits a string on some delimiter value. The second is it returns the Nth token.
Note
index
counts from 1, not from 0.
Syntax
Like many functions in DataPrime, splitParts
supports two notations, function and method notation. These interchangeable forms allow flexibility in how you structure expressions.
Arguments
Name | Type | Required | Description |
---|---|---|---|
string | string | true | The string to split |
delimiter | string | true | The deliter on which to split the string |
index | number | true | The index of the desired split strings. |
Example - Capturing domain from email
Consider the following document:
If I want to extract the domain from this email, I can do it in one line, using the splitParts
function.
This results in the following document:
Try it yourself
Open up your log explore screen and run the following command:
Theme
Light