Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,16 @@ RETURN count(p) AS count

| Queries no longer require xref:clauses/with.adoc[`WITH`] to transition between reading and writing operations.

a|
label:functionality[]
label:updated[]
[source, cypher, role="noheader"]
----
RETURN replace("hello world", "l", "", 1)
----

| The xref:functions/string.adoc#functions-replace[`replace()`] function now accepts an optional `limit` argument, defining the number of times the search string is replaced.

|===

=== New in Cypher 25
Expand Down
24 changes: 22 additions & 2 deletions modules/ROOT/pages/functions/string.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -323,12 +323,13 @@ RETURN normalize('\uFE64', NFKC) = '\u003C' AS result

.Details
|===
| *Syntax* 3+| `replace(original, search, replace)`
| *Syntax* 3+| `replace(original, search, replace [, limit])`
| *Description* 3+| Returns a `STRING` in which all occurrences of a specified search `STRING` in the given `STRING` have been replaced by another (specified) replacement `STRING`.
.4+| *Arguments* | *Name* | *Type* | *Description*
.5+| *Arguments* | *Name* | *Type* | *Description*
| `original` | `STRING` | The string to be modified.
| `search` | `STRING` | The value to replace in the original string.
| `replace` | `STRING` | The value to be inserted in the original string.
| `limit` | `STRING` | The maximum amount of times the search value should be replaced in the string, starting from the left. label:new[Introduced in Neo4j 2025.06]
| *Returns* 3+| `STRING`
|===

Expand All @@ -337,6 +338,7 @@ RETURN normalize('\uFE64', NFKC) = '\u003C' AS result

| If any argument is `null`, `null` will be returned.
| If `search` is not found in `original`, `original` will be returned.
| If `limit` is not defined, all occurrences of the search will be replaced.

|===

Expand All @@ -362,6 +364,24 @@ RETURN replace("hello", "l", "w")

|===

.Query with limit
// tag::functions_string_replace[]
[source, cypher, indent=0]
----
RETURN replace("hello", "l", "w", 1)
----
// end::functions_string_replace[]

.Result
[role="queryresult",options="header,footer",cols="1*<m"]
|===

| replace("hello", "l", "w", 1)
| "hewlo"
1+d|Rows: 1

|===

======


Expand Down