I'm storing e-mail addresses within some user nodes that I'm trying to match against, however the (?i)
case-insensitive option doesn't appear to work when a +
is added in the mail address. I use these to test, for example [email protected]
.
Setting up test nodes:
CREATE (uWithoutSymbol:USER {
email: '[email protected]'
})
CREATE (uWithSymbol:USER {
email: '[email protected]'
})
The Cypher queries:
MATCH (u:USER)
// This works
WHERE u.email =~ '(?i)[email protected]'
RETURN u
MATCH (u:USER)
// This returns nothing
WHERE u.email =~ '(?i)[email protected]'
RETURN u
I tried going for the case-insensitive unicode one: (?ui)
, but also no luck. Any ideas?
The plus symbol '+' has special meaning in regex; escape it:
The plus sign means "one or more of the previous term", so your attempt would match
"[email protected]"
or"[email protected]"
.Technically, you should probably escape the dot too:
because without escaping the dot, it will match any character there, eg it will match
"john+business@doeAcom"
or"john+business@doe#com"
too.Thanks to @Stefan for pointing out the double-backslash needed to create a single literal backslash for the regex