Spencer Attridge
Spencer Attridge

Reputation: 77

Neo4j Cypher Query Regular Expression using a property in a regular expression

How do you return a set of two types of nodes using the property of one, in a regular expression

ie A node (c) with the value of 'Mary Jane Smith' and a node (d) with the value of 'Mary'

I have issues if I try

Match (c:Char_Name), (d:Char) where c.value =~ '.'+d.value+'.' return c,d limit 10

(the c node is a fullname, the d node are made of elements of those names).

Upvotes: 1

Views: 1495

Answers (1)

JohnMark13
JohnMark13

Reputation: 3739

This might be a bit sketchy, but it works in the console.

MATCH (d:Char)
WITH d, "." + d.value + "." AS regex
MATCH (c:Char_Name)
WHERE c.value =~ regex
RETURN c, d
LIMIT 10

Upvotes: 1

Related Questions