cancel
Showing results forΒ 
Search instead forΒ 
Did you mean:Β 

Course: Introduction to Neo4j exercise 4.9 Taking It Further regex solution

brucemcminn
Node Link

Hello. I'm looking for the solution to this exercise using a regular expression. Here are the instructions:

  • Retrieve all movies in the database that have love in their tagline and return the movie titles
  • Retrieve movies in the database, specifying a regular expression for the content of the tagline .
    Here's what I tried:
MATCH (m:Movie)
WHERE m.tagline =~'love'
RETURN m

and

MATCH (m:Movie)
WHERE m.tagline =~'love.*'
RETURN m

Both returned (no changes, no records).
Thanks for any insight. πŸ™‚

1 ACCEPTED SOLUTION

Cobra
Ninja
Ninja

Hello @brucemcminn and welcome to the Neo4j community

Can you try this query?

MATCH (m:Movie)
WHERE m.tagline =~ '(?i).*love.*'
RETURN m.title AS title

You can have more information here.

Regards,
Cobra

View solution in original post

2 REPLIES 2

Cobra
Ninja
Ninja

Hello @brucemcminn and welcome to the Neo4j community

Can you try this query?

MATCH (m:Movie)
WHERE m.tagline =~ '(?i).*love.*'
RETURN m.title AS title

You can have more information here.

Regards,
Cobra

Thanksfor the kind welcome! I learned a little bit more about regex in the last few weeks and see that I need to add the .* at the beginning as well. Using case insensitive (?i) makes it more robust.


Sorry I didn't see your reply sooner.

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

OnΒ November 16 and 17 for 24 hours across all timezones, you’ll learn about best practices for beginners and experts alike.