Copy as Markdown[Open in ChatGPT](https://chatgpt.com/?q=Read%20https%3A%2F%2Fdocs-docusaurus.kinsta.page%2Fdataprime%2Flanguage-reference%2Ffunctions-reference%2Fstring%2Fregexpsplitparts.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%2Fregexpsplitparts.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)

# `regexpSplitParts`

## Description

Splits a string using a regular expression as the delimiter and return the token at the specified index. The index starts at 1, not 0.

## Syntax

Like many functions in DataPrime, `regexpSplitParts` 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

```
regexpSplitParts(value: string, delimiter: regexp, index: number): string
```

```
(value: string).regexpSplitParts(delimiter: regexp, index: number): string
```

## Arguments

| Name        | Type     | Required | Description                                  |
| ----------- | -------- | -------- | -------------------------------------------- |
| `value`     | `string` | **true** | The string to split                          |
| `delimiter` | `regexp` | **true** | The regular expression used as the delimiter |
| `index`     | `number` | **true** | The 1-based index of the token to return     |

## Example

**Extract a value from inconsistently spaced key-value data**

Consider the following document:

```
{

    "values": "val=4 val2=8  val3=9   val4=10"

}
```

Use `regexpSplitParts` with a whitespace pattern to split the string and return the third token:

### Example query

* Function notation
* Method notation

```
create val from regexpSplitParts(values, /s+/, 3)
```

```
create val from values.regexpSplitParts(/s+/, 3)
```

### Example output

```
{

    "values": "val=4 val2=8  val3=9   val4=10",

    "val": "val3=9"

}
```
