# `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://coralogix.com/docs/dataprime/language-reference/functions-reference/index.md), **function** and **method** notation. These interchangeable forms allow flexibility in how you structure expressions.

```dataprime
splitParts(value: string, delimiter: string, index: number): string
```

```dataprime
(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:

```json
{
    "email": "chris@coralogix.com"
}
```

Use `splitParts` to extract the domain in one step:

### Example query

```dataprime
create domain from splitParts(email, '@', 2)
```

```dataprime
create domain from email.splitParts('@', 2)
```

### Example output

```json
{
    "email": "chris@coralogix.com",
    "domain": "coralogix.com"
}
```
