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

  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