# `arraySplit`

## Description

Returns an array of substrings by splitting a string using the specified delimiter.

- The delimiter can be either a `string` or a `regexp`.

## Syntax

Like many functions in DataPrime, `arraySplit` 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
arraySplit(string: string, delimiter: regexp | string): array<string>
```

```dataprime
(string: string).arraySplit(delimiter: regexp | string): array<string>
```

## Arguments

| Name      | Type   | Required | Description         |
| --------- | ------ | -------- | ------------------- |
| string    | string | **true** | The string to split |
| delimiter | regexp | string   | **true**            |

## Example

**Use case: Extract first and last names from a full name**

Suppose you have a field containing a full name. Consider the following input:

```json
{
    "name": "Al Gorithm"
}
```

By splitting the `name` field on a space, you can extract the first and last names into separate fields.

### Example query

```dataprime
create first_name from arraySplit(name, ' ')[0]
| create last_name from arraySplit(name, ' ')[1]
```

```dataprime
create first_name from name.arraySplit(' ')[0]
| create last_name from name.arraySplit(' ')[1]
```

### Example output

The result will include new fields for the first and last names:

```json
{
    "name": "Al Gorithm",
    "first_name": "Al",
    "last_name": "Gorithm"
}
```
