apoc.text.indexesOf

Function

apoc.text.indexesOf(text String, lookup String, from Integer, to Integer) - returns all occurences of the lookup string in the given string, or an empty list if not found.

Signature

apoc.text.indexesOf(text :: STRING?, lookup :: STRING?, from = 0 :: INTEGER?, to = -1 :: INTEGER?) :: (LIST? OF ANY?)

Input parameters

Name Type Default

text

STRING?

null

lookup

STRING?

null

from

INTEGER?

0

to

INTEGER?

-1

Usage Examples

RETURN apoc.text.indexesOf("Hello World, Hello, Hello", 'Hello') AS output;
Table 1. Results
output

[0, 13, 20]

Starting from index 6, find the occurrences of 'Hello',
RETURN apoc.text.indexesOf("Hello World, Hello, Hello", 'Hello', 6) AS output;
Table 2. Results
output

[13, 20]

Starting from index 6 up to index 20, find the occurrences of 'Hello',
RETURN apoc.text.indexesOf("Hello World, Hello, Hello", 'Hello', 6, 20) AS output;
Table 3. Results
output

[13]