0

I am trying with this query

MATCH(u:User) WHERE ANY(name IN ['ACB','xYz'] WHERE u.first_name =~ "(?i).*name.*") RETURN u

it is considering (?i).*name.* as static text instead of dynamic value from name IN ['ACB','xYz'].

Smajl
  • 7,555
  • 29
  • 108
  • 179
  • yes, regex are static text. But in your example, I think you can add "['ACB','xYz']" directly in the regex, it's not dynamic here, right ? – logisima Oct 20 '15 at 11:59
  • @logisima it is also dynamic. coming in request. Right now just to let the work done I have traversed the whole array and added regex with each element **ex. search_param = search_param.map(function (ele) { return '.*(?i)' + ele + '.*' });** but I dont want to traverse the array. – Sachin Rajput Oct 20 '15 at 12:05

1 Answers1

0

You can assemble a regex expression using string concatenation. This case however needs some toString hinting:

MATCH(u:User) WHERE ANY(name IN ['ACB','xYz'] 
    WHERE u.first_name =~ toString("(?i).*" +name +".*")) 
RETURN u
Stefan Armbruster
  • 39,465
  • 6
  • 87
  • 97