Skip to main content

SPLIT_BY_REGEXP

Description​

Split the input string into an array of strings according to the specified regular expression.

Syntax​

SPLIT_BY_REGEXP ( <str>, <pattern> [, <max_limit>] )

Parameters​

ParameterDescription
<str>The string to be split
<pattern>Regular expression
<max_limit>Optional parameter, whether to limit the number of elements in the returned string array. The default is no limit

Return Value​

Return an array of strings split according to the specified regular expression. Special cases:

  • If any of the parameters is NULL, NULL is returned.

Examples​

SELECT split_by_regexp('abcde',"");
+------------------------------+
| split_by_regexp('abcde', '') |
+------------------------------+
| ["a", "b", "c", "d", "e"] |
+------------------------------+
select split_by_regexp('a12bc23de345f',"\\d+");
+-----------------------------------------+
| split_by_regexp('a12bc23de345f', '\d+') |
+-----------------------------------------+
| ["a", "bc", "de", "f"] |
+-----------------------------------------+