[Python] Python docstring + Neo4J cypher query seems to cause regexp error

Discussão em 'Python' iniciado por Stack, Março 5, 2025.

  1. Stack

    Stack Membro Participativo

    I have a cypher snippet like this:

    where my_node.my_column =~ ("(?i).*\\." + {my_var})


    The idea is to match a path-like string. For example, my_column could have a value of db.schema.MY_TABLE and I want to pass "My_TaBlE" in my Python cypher statement. This should match.

    However, I am getting a Cypher error on that statement; Specifically, it does not like the final "." in the regexp. It is like I am not escaping it correctly. The docs say Java regexp is used under the hood.

    Right now I am using:

    where my_node.my_column =~ ('(?i).*' + '.' + {table_name})


    This seems to work, but I can't honestly say if the period is matching any character or the literal period character.

    If it matters, my Cypher query is in a Python docstring.

    How can I escape the period? Is there a better way to express what I am looking for?

    Continue reading...

Compartilhe esta Página