samcorcos
samcorcos

Reputation: 2478

Global match regular expression with Neo4j Cypher query

I am searching in Neo4j using a regular expression. I would like this search to be global. As it stands, the search will only find words that start with inputted letters in the regular expression:

MATCH (a) 
WHERE a.name =~ '(?i)bob.+' 
RETURN a.name

So it will find the name Bob Smith no problem, but it will not find John McBobberson. How do I find John McBobberson while retaining the input "bob" as the search query?

Upvotes: 2

Views: 597

Answers (1)

Luanne
Luanne

Reputation: 19373

MATCH (a) 
WHERE a.name =~ '(?i).*bob.+' 
RETURN a.name

should find John McBobberson, but I don't think it will find John McBob. This one should find both.

MATCH (a) 
WHERE a.name =~ '(?i).*bob.*' 
RETURN a.name

Upvotes: 2

Related Questions