O'Reilly logo

Neo4j Cookbook by Ankur Goel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Regular expressions with Cypher

By default, Cypher works on an exact match, which is case sensitive in nature. Many times we will know the pattern we want to match, but not the exact value. In this recipe, we will learn to use regex with a Cypher query.

Getting ready

To work through this recipe, you will need to create the nodes and relationships for which data has been provided with the code files.

How to do it...

We have divided this recipe into the following problem sets:

  • Getting the details: Let's get all the Airport names starting with the letter H:
    MATCH (n) WHERE "Airport" in LABELS(n) AND n.name =~ '^H.*' RETURN n

    You can also specify a label along with the node, as shown in the following code:

    MATCH (n:Airport)

    The following screenshot shows the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required