diff --git a/pages/advanced-algorithms/available-algorithms.mdx b/pages/advanced-algorithms/available-algorithms.mdx index 749aa1ea2..5854ee7c7 100644 --- a/pages/advanced-algorithms/available-algorithms.mdx +++ b/pages/advanced-algorithms/available-algorithms.mdx @@ -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) | diff --git a/pages/advanced-algorithms/available-algorithms/text.mdx b/pages/advanced-algorithms/available-algorithms/text.mdx index 2c738184f..152bb3a1a 100644 --- a/pages/advanced-algorithms/available-algorithms/text.mdx +++ b/pages/advanced-algorithms/available-algorithms/text.mdx @@ -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). + + +This function is equivalent to **apoc.text.compareCleaned**. + + + +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`. + + +{

Input:

} + +- `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`. + +{

Output:

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

Usage:

} + +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 | ++--------+ +```