regex - When using the following regexp query, how can I escape the special character in the keyword? -


when using following regexp query, how can escape special character (') in keyword? can't seem find place \' sequence.

with ["freda's"] keywords reduce(s = [], x in keywords | s + ('(?i).*' + x + '.*')) regexps match (p:product) all(x in regexps p.name =~ x) return p 

your cypher query work written, issue how using programming language generate strings in with clause.

practically speaking, should not passing keywords array in way have shown, anyway. more performant , secure approach (which may work around issue) pass array parameter. parameter value native array in whatever language using.

if passed keywords array parameter, query be:

with reduce(s = [], x in {keywords} | s + ('(?i).*' + x + '.*')) regexps match (p:product) all(x in regexps p.name =~ x) return p; 

by way, sure want use all() instead of any()?


Comments