Skip to main content

Overview

The constants module exports useful regular expressions and symbols for Arabic text processing.

PATTERN_ENDS_WITH_PUNCTUATION

Regular expression to match punctuation at the end of a string.
PATTERN_ENDS_WITH_PUNCTUATION
RegExp
Pattern: /[.!?؟؛]$/Matches period (.), exclamation mark (!), question mark (?), Arabic question mark (؟), or Arabic semicolon (؛) at the end of a string.
Example
import { PATTERN_ENDS_WITH_PUNCTUATION } from 'bitaboom';

console.log(PATTERN_ENDS_WITH_PUNCTUATION.test('Hello world.')); // true
console.log(PATTERN_ENDS_WITH_PUNCTUATION.test('مرحبا؟')); // true
console.log(PATTERN_ENDS_WITH_PUNCTUATION.test('No punctuation')); // false

SALUTATION_SYMBOL

The Unicode symbol (ﷺ) used to represent Islamic salutations.
SALUTATION_SYMBOL
string
Value: 'ﷺ' (U+FDFA)This symbol represents “peace be upon him” (PBUH) and is used by replaceSalutationsWithSymbol.
Example
import { SALUTATION_SYMBOL } from 'bitaboom';

console.log(SALUTATION_SYMBOL); // ﷺ

ARABIC_DIACRITICS_REGEX

Regular expression to match Arabic diacritical marks (tashkeel/harakāt).
ARABIC_DIACRITICS_REGEX
RegExp
Pattern: /[\u064B-\u0652\u0670\u0617-\u061A\u06D6-\u06ED]/gMatches all Arabic diacritics including fatha, damma, kasra, sukun, shadda, tanween, and others.
Example
import { ARABIC_DIACRITICS_REGEX } from 'bitaboom';

const text = 'بِسْمِ اللَّهِ';
const withoutDiacritics = text.replace(ARABIC_DIACRITICS_REGEX, '');
console.log(withoutDiacritics); // بسم الله

ABBREVIATION_REGEX

Regular expression for matching common salutation abbreviations.
ABBREVIATION_REGEX
RegExp
Internal regex used by replaceSalutationsWithSymbol to match abbreviations like PBUH, SAW, SAWS, etc.
This constant is primarily used internally by the transliteration module.

ENGLISH_PHRASE_REGEX

Regular expression for matching English salutation phrases.
ENGLISH_PHRASE_REGEX
RegExp
Internal regex used by replaceSalutationsWithSymbol to match English phrases like “peace be upon him”, “may Allah bless him”, etc.
This constant is primarily used internally by the transliteration module.

PARENTHETICAL_REGEX

Regular expression for matching parenthetical salutation forms.
PARENTHETICAL_REGEX
RegExp
Internal regex used by replaceSalutationsWithSymbol to match salutations enclosed in parentheses.
This constant is primarily used internally by the transliteration module.

SYMBOL_CLEANUP_REGEX

Regular expression for cleaning up dashes around the salutation symbol.
SYMBOL_CLEANUP_REGEX
RegExp
Pattern: /[‒–—―-][ \t]*ﷺ[ \t]*[‒–—―-]?|ﷺ[ \t]*[‒–—―-]/gMatches various dash characters around the ﷺ symbol for cleanup purposes.
Example
import { SYMBOL_CLEANUP_REGEX } from 'bitaboom';

const text = '— ﷺ —';
const cleaned = text.replace(SYMBOL_CLEANUP_REGEX, 'ﷺ');
console.log(cleaned); // ﷺ

Usage notes

Most of these constants are exported for advanced use cases. For common tasks, use the higher-level functions like replaceSalutationsWithSymbol or makeDiacriticInsensitiveRegex instead.
The regex constants are compiled once and can be reused efficiently across multiple operations.

Build docs developers (and LLMs) love