Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace regular expressions in cypher

Tags:

neo4j

cypher

I can search for regular expressions in cypher

MATCH (n:model) WHERE n.name =~ '.*&.*;.*' RETURN n.name

but can I also replace them? I would like to write something like

MATCH (n:model) RETURN replace(n.name, ~'&.*;', '_');
like image 829
Dirk Horsten Avatar asked Oct 20 '22 19:10

Dirk Horsten


1 Answers

There is a replace function in cypher, but it does not replace regexps, just simple strings. Maybe a feature request for replaceRegex could be done?

An workaround would be to do this programatically, after you return the names (if you use call cypher queries from another application).

like image 73
zaboco Avatar answered Oct 27 '22 21:10

zaboco