Skip to content
Open
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
1 change: 1 addition & 0 deletions pages/advanced-algorithms/available-algorithms.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ Running `SHOW QUERY CALLABLE MAPPINGS` requires the `CONFIG` privilege.
| apoc.text.format | Formats strings using the C++ fmt library | [text.format()](/advanced-algorithms/available-algorithms/text#format) |
| apoc.text.replace | Replaces substrings matching regex with replacement | [text.replace()](/advanced-algorithms/available-algorithms/text#replace) |
| apoc.text.regReplace | Replaces substrings matching regex with replacement | [text.regReplace()](/advanced-algorithms/available-algorithms/text#regreplace) |
| apoc.text.compareCleaned | Compares two strings for equality after normalization | [text.compare_cleaned()](/advanced-algorithms/available-algorithms/text#compare_cleaned) |
| apoc.util.md5 | Gets MD5 hash of concatenated string representations | [util_module.md5()](/advanced-algorithms/available-algorithms/util_module#md5) |
| apoc.util.validatePredicate | Raises exception if predicate yields true with parameter interpolation | [mgps.validate_predicate()](/advanced-algorithms/available-algorithms/mgps#validate_predicate) |
| db.awaitIndexes | No-op compatibility shim for clients that wait for index creation (e.g. the Neo4j Spark connector) | [mgps.await_indexes()](/advanced-algorithms/available-algorithms/mgps#await_indexes) |
Expand Down
43 changes: 43 additions & 0 deletions pages/advanced-algorithms/available-algorithms/text.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -297,3 +297,46 @@ Result:
| 1 |
+--------+
```

### `compare_cleaned()`

Compares two strings for equality after normalizing each one: keeping only ASCII
letters and digits, converting them to lowercase, and dropping everything else
(accents, punctuation, whitespace, and non-ASCII characters).

<Callout type="info">
This function is equivalent to **apoc.text.compareCleaned**.
</Callout>

<Callout type="info">
Normalization is limited to ASCII and performs no Unicode folding, so accented
and non-ASCII letters are dropped rather than reduced to a base letter. For
example, `café` cleans to `caf` and is therefore not equal to `cafe`.
</Callout>

{<h4 className="custom-header"> Input: </h4>}

- `text1: string` ➡ The first string to normalize and compare. A `null` value results in `false`.
- `text2: string` ➡ The second string to normalize and compare. A `null` value results in `false`.

{<h4 className="custom-header"> Output: </h4>}

- `boolean` ➡ `true` if the two normalized strings are equal, and `false` otherwise.

{<h4 className="custom-header"> Usage: </h4>}

Use the following query to compare two strings while ignoring case and punctuation:

```cypher
RETURN text.compare_cleaned("Hello, World!", "hello world") AS result;
```

Result:

```plaintext
+--------+
| result |
+--------+
| true |
+--------+
```