2

I have node for user with FirstName, LastName properties. Now I want to search some value in both properties from both site. Let I have to explain.

FirstName  LastName
---------  --------
Manish     Pal
Pal        Dharmesh
Rajpal     Yadav
sharma     shreepal

Now I want to search which node's firstname or lastname contain 'pal'. I have written query like this.

START users=node(*) 
WHERE (users.FirstName =~ '(?i)pal.*' OR users.LastName =~ '(?i)pal.*') 
RETURN users;

It gives me just 2 nodes, but I want all node with is containing 'pal'

If I try like this

START users=node(*) 
WHERE (users.FirstName =~ '(?i)*.pal.*' OR users.LastName =~ '(?i)*.pal.*') 
RETURN users;

It is giving me following error.

"PatternSyntaxException"

Dangling meta character '' near index 4 (?i).ant. ^*

I have set example here for your ready reference.

Thanks.

4

1 回答 1

6

第二个查询包含无效的正则表达式语法。我想你的意思是:

START users=node(*) 
WHERE (users.FirstName =~ '(?i).*pal.*' OR users.LastName =~ '(?i).*pal.*') 
RETURN users

请注意您帖子中查询的不同之处:

  • '(?i)*.pal.*'在你的帖子中,和
  • '(?i).*pal.*'在上面的查询中

星号*表示我之前的表达式 [星号] 可能出现任意次数,包括零。但是(?i)不是正则表达式,而只是一个忽略实际表达式大小写的修饰符。我想你的意思是.*。正则表达式.匹配任何字符,星号允许任何字符出现任意次数。

因此,'(?i).*pal.*'说:[忽略大小写] <任意字符数><确切的字符序列:“pal”><任意字符数>

上面的查询为我返回了四个结果:

users.FirstName  | users.LastName
---------------------------------
sharma           | shreepal
Rajpal           | Yadav
Pal              | Dharmesh     
Manish           | Pal

如果我理解正确的话,这就是你想要的。

于 2013-08-02T11:51:23.870 回答