VeloDB Cloud
SQL Manual
Functions
string-functions
search
multi_search_all_positions

multi_search_all_positions

Description

Syntax

ARRAY<INT> multi_search_all_positions(VARCHAR haystack, ARRAY<VARCHAR> needles)

Searches for the substrings needles in the string haystack, and returns array of positions of the found corresponding substrings in the string. Positions are indexed starting from 1.

example

mysql> select multi_search_all_positions('Hello, World!', ['hello', '!', 'world']);
+----------------------------------------------------------------------+
| multi_search_all_positions('Hello, World!', ['hello', '!', 'world']) |
+----------------------------------------------------------------------+
| [0,13,0]                                                             |
+----------------------------------------------------------------------+

mysql> select multi_search_all_positions('abc', ['a', 'bc', 'd']);
+-----------------------------------------------------+
| multi_search_all_positions('abc', ['a', 'bc', 'd']) |
+-----------------------------------------------------+
| [1,2,0]                                             |
+-----------------------------------------------------+

keywords

MULTI_SEARCH,SEARCH,POSITIONS