> ## Documentation Index
> Fetch the complete documentation index at: /documents/llms.txt
> Use this file to discover all available pages before exploring further.

# regexp_split

> Split string str by regexp expression pattern, return maximum max_split elements in ARRAY<VARCHAR> type.

Split string `str` by regexp expression `pattern`, return maximum `max_split` elements in `ARRAY<VARCHAR>` type.

## Syntax

```Haskell theme={null}
regexp_split(str, pattern[, max_split])
```

## Parameters

`str`: required, the string to split, which must evaluate to a `VARCHAR` value.

`pattern`: required, the regexp expression pattern used to split, which must evaluate to a `VARCHAR` value.

`max_split`: optional, the number of maximum elements in the output value, which must evaluate to an `INT` value.

## Return value

Returns an `ARRAY<VARCHAR>` value.

## Examples

```Plain Text theme={null}
mysql> select regexp_split('StarRocks', '');
+---------------------------------------+
| regexp_split('StarRocks', '')         |
+---------------------------------------+
| ["S","t","a","r","R","o","c","k","s"] |
+---------------------------------------+

mysql> select regexp_split('StarRocks', '[SR]');
+-----------------------------------+
| regexp_split('StarRocks', '[SR]') |
+-----------------------------------+
| ["","tar","ocks"]                 |
+-----------------------------------+

mysql> select regexp_split('StarRocks', '[SR]', 1);
+--------------------------------------+
| regexp_split('StarRocks', '[SR]', 1) |
+--------------------------------------+
| ["StarRocks"]                        |
+--------------------------------------+

mysql> select regexp_split('StarRocks', '[SR]', 2);
+--------------------------------------+
| regexp_split('StarRocks', '[SR]', 1) |
+--------------------------------------+
| ["","tarRocks"]                      |
+--------------------------------------+
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.