apoc.text.replace

This function is deprecated. Use Cypher’s string.replace() function instead.

Details

Syntax

apoc.text.replace(text, regex, replacement)

Description

Finds and replaces all matches found by the given regular expression with the given replacement.

Arguments

Name

Type

Description

text

STRING

The string to be modified.

regex

STRING

The regular expression pattern to replace in the original string.

replacement

STRING

The value to be inserted in the original string.

Returns

STRING

Usage Examples

The following returns the string with all matches of the regular expression replaced by the replacement string using both APOC and Cypher:

apoc.text.replace
RETURN apoc.text.replace('Hello World!', '[^a-zA-Z]', '') AS output;
Using Cypher’s string.regexReplace
RETURN string.regexReplace('Hello World!', '[^a-zA-Z]', '') AS output;
Results
output

"HelloWorld"

apoc.text.replace
RETURN apoc.text.replace('GDS is a Neo4j Product', 'GDS', 'Bloom') AS output;
Using Cypher’s string.regexReplace
RETURN string.regexReplace('GDS is a Neo4j Product', 'GDS', 'Bloom') AS output;
Results
output

"Bloom is a Neo4j Product"