Copy as Markdown[Open in ChatGPT](https://chatgpt.com/?q=Read%20https%3A%2F%2Fdocs-docusaurus.kinsta.page%2Fdataprime%2Flanguage-reference%2Ffunctions-reference%2Fstring%2Fsplitparts.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)[Open in Claude](https://claude.ai/new?q=Read%20https%3A%2F%2Fdocs-docusaurus.kinsta.page%2Fdataprime%2Flanguage-reference%2Ffunctions-reference%2Fstring%2Fsplitparts.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)

# `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](https://docs-docusaurus.kinsta.page/dataprime/language-reference/functions-reference/.md),<!-- --> **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"

}
```
