multi_search_all_positions

Description

Syntax

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

搜索字符串 haystack 中的子字符串 needles,并返回在 haystack 中找到的相应 needles 的位置数组。位置的下标从 1 开始。

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. +----------------------------------------------------------------------+
  7. mysql> select multi_search_all_positions('abc', ['a', 'bc', 'd']);
  8. +-----------------------------------------------------+
  9. | multi_search_all_positions('abc', ['a', 'bc', 'd']) |
  10. +-----------------------------------------------------+
  11. | [1,2,0] |
  12. +-----------------------------------------------------+

keywords

  1. MULTI_SEARCH,SEARCH,POSITIONS