REGEX_SPLIT()

All functions > STRING > REGEX_SPLIT()

Splits a string by a regular expression pattern and returns the parts between matches as an array.

Signatures

Returns: Array of substrings between matches; single-element array containing the original string when there is no match; NULL if the haystack is NULL

REGEX_SPLIT(string: VARCHAR, pattern: VARCHAR) → ARRAYVARCHAR
sql
ParameterTypeRequiredDescription
stringVARCHARYesString to split
patternVARCHARYesRegular expression pattern to split on

Notes

  • Returns the parts between matches, not the matches themselves; use REGEX_EXTRACT_ALL to get the matched text instead
  • Consecutive matches (or a match at the start/end of the string) produce empty strings in the result array
  • Not available on every deployment target (unsupported targets fail translation)

See also

Examples

FeatureQL
SELECT
    f1 := REGEX_SPLIT('abc123def456ghi', '[0-9]+'), -- Split by digit groups
    f2 := REGEX_SPLIT('one::two:::three', ':+'), -- Split by one or more colons
    f3 := REGEX_SPLIT('hello   world  foo', '\s+'), -- Split by whitespace
    f4 := REGEX_SPLIT(',a,b,', ','), -- Leading and trailing delimiters produce empty strings
    f5 := REGEX_SPLIT('no match here', '[0-9]+'), -- No match returns original string in array
    f6 := REGEX_SPLIT(NULL(VARCHAR), ',') -- NULL haystack
;
Result
f1 ARRAYf2 ARRAYf3 ARRAYf4 VARCHARf5 ARRAYf6 ARRAY
[abc, def, ghi][one, two, three][hello, world, foo][(empty), a, b, (empty)][no match here]NULL

Last update at: 2026/05/26 17:22:09