Skip to main content

Function signature

Advanced Arabic normalization for search indexing. Handles Unicode normalization, variant unification, and cleanup.

Parameters

string
required
The input Arabic text to normalize

Returns

string
The normalized string with all transformations applied

What transformations are applied

The function applies the following transformations in order:
  1. Removes tashkeel (diacritics) - Strips all diacritical marks and Quranic symbols
  2. Unicode normalization - Applies NFC (Canonical Decomposition followed by Canonical Composition)
  3. Removes dagger alif and tatweel - Removes U+0670 (dagger alif) and U+0640 (tatweel/kashida)
  4. Unifies alef variants - Converts إ أ آ ٱ → ا (regular alef)
  5. Unifies hamza variants - Converts ؤ ئ ء → ء (standalone hamza)
  6. Unifies alif maqsura - Converts ى → ي (yaa)
  7. Removes control characters - Strips CRLF and non-Arabic symbols
  8. Normalizes whitespace - Replaces multiple spaces with single space
  9. Trims whitespace - Removes leading and trailing whitespace

Use case

Preparing user input for searching. This function unifies alef variants, removes tashkeel, and normalizes text to ensure consistent matching across different writing styles.

Examples

Basic normalization

Before and after

Using in search filter

Empty input handling