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 to pass parameter with regex query

Hello all,

I am trying to query using regular expression in py2neo. However, I ran this query, but It did not work. I tried running the same query directly in Cypher and it worked. I do not know what I am missing.

I appreciate any help.

Thanks.
Bader


            propertyNode = tx.run("MATCH (n) WHERE n.name=~(?i)$x(s?) RETURN n.id, labels(n)", x=word).data()
3 REPLIES 3

Have you tried:

propertyNode = tx.run("MATCH (n) WHERE n.name=~'(?i)' + $x +'(s?)' RETURN n.id, labels(n)", x=word).data()

It did not work either. I want to match keywords like cartype or carType.

What are you using (s?) for?

This actually works:

return "carType"=~ '(?i)' + "car" + '\S+'
Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

All the sessions of the conference are now available online