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.

Why does question mark blocks case insensitive matching?

lingvisa
Graph Fellow

match (n) where n.name = 'Okay?Okay?' return n

This can successfully return the node from the graph. However,

match (n) where n.name =~ '(?i)Okay?Okay?' return n

This returns nothing.

1 ACCEPTED SOLUTION

Hi @lingvisa
Sorry, My description was incorrect.
The "any character" is period.
The question mark indicates zero or one occurrences of the preceding element.

You can find "Okay?Okay?", "okay?okay?", "Okay1Okay2", "OkayAOkayB".

MATCH (n)
  WHERE n.name =~ '(?i)Okay.Okay.'
RETURN n

View solution in original post

4 REPLIES 4

Hi @lingvisa

The "=~ '(?i)Okay?Okay?'" is a regular expression.
This question mark in a regular expression means some character.

If you write a backslash before the question mark, it will work correctly.

MATCH (n)
  WHERE n.name =~ '(?i)Okay\?Okay\?'
RETURN n

further detail on regular expressions at WHERE - Neo4j Cypher Manual

Shouldn't the question mark '?' represent any character? If that's the case, it does not have to be escapeted?

Hi @lingvisa
Sorry, My description was incorrect.
The "any character" is period.
The question mark indicates zero or one occurrences of the preceding element.

You can find "Okay?Okay?", "okay?okay?", "Okay1Okay2", "OkayAOkayB".

MATCH (n)
  WHERE n.name =~ '(?i)Okay.Okay.'
RETURN n