apoc.text.indexesOf

Function

apoc.text.indexesOf(text STRING, lookup STRING, from INTEGER, to INTEGER) - returns all occurrences 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<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]