multi_search_all_positions

Description

Syntax

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

返回一个 ARRAY,其中第 i 个元素为 needles 中第 i 个元素 needle,在字符串 haystack 中首次出现的位置。位置从1开始计数,0代表未找到该元素。大小写敏感。

example

1. mysql> select multi_search_all_positions('Hello, World!', ['hello', '!', 'world']);
2. +----------------------------------------------------------------------+
3. | multi_search_all_positions('Hello, World!', ['hello', '!', 'world']) |
4. +----------------------------------------------------------------------+
5. | [0,13,0]                                                             |
6. +----------------------------------------------------------------------+

8. select multi_search_all_positions("Hello, World!", ['hello', '!', 'world', 'Hello', 'World']);
9. +---------------------------------------------------------------------------------------------+
10. | multi_search_all_positions('Hello, World!', ARRAY('hello', '!', 'world', 'Hello', 'World')) |
11. +---------------------------------------------------------------------------------------------+
12. | [0, 13, 0, 1, 8]                                                                            |
13. +---------------------------------------------------------------------------------------------+

keywords

1. MULTI_SEARCH,SEARCH,POSITIONS