Skip to content

normalizeArabicYeh

Homayoun edited this page Jul 10, 2026 · 1 revision

Introduced in v1.2.0

⚠️ Version Recommendation: Always install and use the latest version of rtl-text-tools (npm install rtl-text-tools@latest). While this specific feature was introduced in an earlier version, the latest release includes crucial bug fixes, better edge-case handling, and improved legacy browser compatibility. Avoid pinning your project to an old version just to use this function.

Normalizes the Arabic letter Alef Maqsura (Ω‰) to the standard Yeh (ي). In many Arabic dialects (such as Egyptian) and common typing habits, Alef Maqsura is used interchangeably with Yeh at the end of words. Normalizing these characters ensures consistent search results, accurate text comparison, and standardized data storage.

πŸ“ Syntax

normalizeArabicYeh(text: string): string

Parameters

Name Type Description
text string The Arabic text containing Alef Maqsura to normalize.

Returns

  • string : Returns the text with all instances of Alef Maqsura (Ω‰) converted to standard Yeh (ي). Returns the original string unchanged if it is empty, null, or contains no Alef Maqsura.

πŸ’‘ Examples

Basic Usage

import { normalizeArabicYeh } from 'rtl-text-tools';

normalizeArabicYeh("ΨΉΩ„Ω‰");      // "ΨΉΩ„ΩŠ" (Alef Maqsura -> standard Yeh)
normalizeArabicYeh("Ω…Ψ΅Ψ±Ω‰");     // "Ω…Ψ΅Ψ±ΩŠ" (Common Egyptian spelling -> standard)
normalizeArabicYeh("Ω‡Ψ°Ω‰");      // "Ω‡Ψ°Ψ§" -> wait, "Ω‡Ψ°ΩŠ" (End of word Yeh)
normalizeArabicYeh("يوسف");     // "يوسف" (Already standard Yeh -> unchanged)

Search and Text Comparison

When building a search feature or filtering data, users might type words with different Yeh variations depending on their regional dialect or keyboard layout. Normalizing both the database text and the user's query ensures accurate matches:

import { normalizeArabicYeh } from 'rtl-text-tools';

const databaseText = "ΨΉΩ„ΩŠ";     // Stored with standard Yeh
const userQuery = "ΨΉΩ„Ω‰";        // User typed with Alef Maqsura

const normalizedDB = normalizeArabicYeh(databaseText);   // "ΨΉΩ„ΩŠ"
const normalizedQuery = normalizeArabicYeh(userQuery);   // "ΨΉΩ„ΩŠ"

if (normalizedDB === normalizedQuery) {
  console.log("Match found!"); // This will now successfully match
}

🌍 Character Mapping

This function specifically targets the following Unicode character and replaces it with the standard Yeh (\u064A):

Original Character Name Unicode Replaced With
Ω‰ Alef Maqsura \u0649 ي (\u064A)

βš™οΈ Technical Details & Compatibility

  • Direct Replacement: The function uses a standard String.prototype.replace() method with a global regular expression (/\u0649/g) to ensure every instance of the targeted character is replaced.
  • IE11 Compatibility: It avoids modern string methods and the ES6 u regex flag, ensuring full compatibility with legacy browsers like IE11.
  • Safe Execution: If the input is falsy (e.g., null, undefined, or ""), it immediately returns the input without throwing an error.

πŸ“œ Version History

  • v1.2.0: Added normalizeArabicYeh() as part of the Arabic language enhancements for deep text normalization.

πŸš€ rtl-text-tools

npm downloads

πŸ‘¨β€πŸ’» Created by

Homayoun Mohammadi
πŸ”— GitHub β€’ βœ‰οΈ Email

⭐ Love this project? Star it on GitHub to show your support!

Clone this wiki locally