regexp_split_to_array()

Splits the string along the regex

Alias of string_split_regex()

Arguments & returns

2 overloads

regexp_split_to_array(string, regex)

Scalar
Overload link stringregex Returns
#01 VARCHARVARCHAR VARCHAR[]

regexp_split_to_array(string, regex, col2)

Scalar
Overload link stringregexcol2 Returns
#02 VARCHARVARCHARVARCHAR VARCHAR[]

Example

regexp_split_to_array example
SQL
Haybarn WASM 1.5.5-rc3 · In your browser

Engine example · Run to view results.

Catalog examples

SELECT
  string_split_regex('hello world; 42', ';? ');

In other engines

Used in larger rewrites 1

These examples use regexp_split_to_array as one part of a larger SQL translation.

Snowflakestrtok()

SELECT STRTOK('ab')
In DuckDB
SELECT CASE WHEN ' ' = '' AND 'ab' = '' THEN NULL WHEN ' ' = '' AND 1 = 1 THEN 'ab' WHEN ' ' = '' THEN NULL WHEN 1 < 0 THEN NULL WHEN 'ab' IS NULL OR ' ' IS NULL OR 1 IS NULL THEN NULL ELSE LIST_FILTER(REGEXP_SPLIT_TO_ARRAY('ab', CASE WHEN ' ' = '' THEN '' ELSE '[' || REGEXP_REPLACE(' ', '([\[\]^.\-*+?(){}|$\\])', '\\\1', 'g') || ']' END), x -> NOT x = '')[1] END

SQLGlot example ↗