apoc.text.indexesOf

Function APOC Core

apoc.text.indexesOf(text, lookup, from=0, to=-1==len) - finds all occurences of the lookup string in the text, return list, from inclusive, to exclusive, empty list if not found, null if text is null.

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]