Using regular expression in neo4j
cypher, neo4j, regex
Solution
There were 3 problems in your query:
- `(n:)` should be `(n)`, since you are not specifying a label.
- Back slashes must be escaped by a preceding back slash.
- The regex needs to match the entire property value (I assume that your test value was fairly long).
This query should work:
MATCH (n)
WHERE n.Text =~ '.*\\bword\\b.*'
RETURN n;
See here for documentation related to Regular Expressions in Neo4j
Problem
I'm trying to use regular expressions in a cypher `WHERE` clause. I would like to match nodes in which a node's property `Text` contains a specific word, as a word and not part of it. ``` MATCH (n:) WHERE n.Text =~ '\bword\b' return n; ``` This query doesn't return anything although nodes containing the word "word" exist in my graph. Does cypher allow the use of standard regular expressions? Are there limitations in its regular expression implementation?