cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

How do I get the first position of a substring in a string

Reiner
Graph Buddy

I'm looking for a simple string function to get the first position of a substring in a string. Something equivalent of indexOf(), strPos(), charIndex()... Didn't find anything in Cypher or Apoc - only issue 1041, open since 2013?

3 REPLIES 3

There is nothing direct in Cypher. I was totally sure we already had it in apoc.
Gonna add it this week.

As a workaround in the meantime you can use split + length:

RETURN length(split("ab-c","-")[0])

Added an issue here: https://github.com/neo4j-contrib/neo4j-apoc-procedures/issues/896

taffyb
Node Clone

Did apoc.text.indexOf get dropped? I am sure I used it in the past, but in v3.3.0.2 it does not exist

Reiner
Graph Buddy

I'm using 3.5.0.4 and 3.5.0.5, there apoc.text.indexOf exists. In the 4.0rc code also. I'm not sure in which version it was introduced.

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

All the sessions of the conference are now available online