Bitaboom can automatically detect and replace over 130 variations of salutations for Prophet Muhammad with the standardized Unicode symbol ﷺ (U+FDFA).
Basic usage
import { replaceSalutationsWithSymbol } from 'bitaboom';
const text = 'The Prophet sallallahu alayhi wasallam said';
const result = replaceSalutationsWithSymbol(text);
// Result: 'The Prophet ﷺ said'
Latin abbreviations
Common English abbreviations are automatically replaced:
replaceSalutationsWithSymbol('The Prophet PBUH');
// Result: 'The Prophet ﷺ'
replaceSalutationsWithSymbol('Muhammad (SAW) said');
// Result: 'Muhammad ﷺ said'
replaceSalutationsWithSymbol('The Prophet (s. a. w. s.) said');
// Result: 'The Prophet ﷺ said'
replaceSalutationsWithSymbol('PBUH was a title');
// Result: 'ﷺ was a title'
replaceSalutationsWithSymbol('The Prophet (SAW) said');
// Result: 'The Prophet ﷺ said'
replaceSalutationsWithSymbol('Muhammad (SAWS) taught');
// Result: 'Muhammad ﷺ taught'
Latin transliterations
Various romanization schemes are supported:
replaceSalutationsWithSymbol('sallahu alayhi wasallam');
// Result: 'ﷺ'
replaceSalutationsWithSymbol('The Prophet sallallahu alayhi wasallam said');
// Result: 'The Prophet ﷺ said'
Salutations in parentheses are handled correctly:
replaceSalutationsWithSymbol(
'Then the Messenger of Allah (sallahu alayhi wasallam) said'
);
// Result: 'Then the Messenger of Allah ﷺ said'
replaceSalutationsWithSymbol(
'Then the Messenger (peace and blessings be upon him) said'
);
// Result: 'Then the Messenger ﷺ said'
English phrases
Long-form English phrases are recognized:
replaceSalutationsWithSymbol(
`Allah's Messenger (May peace and blessings be upon him) said`
);
// Result: `Allah's Messenger ﷺ said`
replaceSalutationsWithSymbol(
'Prophet (May peace and blessings be upon him) said'
);
// Result: 'Prophet ﷺ said'
Arabic script
The function handles Arabic salutations with and without diacritics:
With diacritics
replaceSalutationsWithSymbol('النبي صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ قال');
// Result: 'النبي ﷺ قال'
Without diacritics
replaceSalutationsWithSymbol('النبي صلى الله عليه وسلم قال');
// Result: 'النبي ﷺ قال'
replaceSalutationsWithSymbol('محمد عليه الصلاة والسلام');
// Result: 'محمد ﷺ'
Multiple occurrences
All salutations in a text are replaced:
const text = `The Prophet sallallahu alayhi wasallam met Muhammad (SAW).`;
const result = replaceSalutationsWithSymbol(text);
// Result: 'The Prophet ﷺ met Muhammad ﷺ.'
Symbol cleanup
The function automatically cleans up surrounding punctuation:
Removing dashes
replaceSalutationsWithSymbol('The Prophet -ﷺ- said');
// Result: 'The Prophet ﷺ said'
Cleaning commas
replaceSalutationsWithSymbol('The Prophet, PBUH, said');
// Result: 'The Prophet ﷺ said'
Parentheses cleanup
replaceSalutationsWithSymbol('Then the Prophet (sallahu alayhi wasallam) said');
// Result: 'Then the Prophet ﷺ said'
Multiline text
The function preserves line breaks:
const input = `Line one
sallallahu alayhi wasallam
Line two`;
replaceSalutationsWithSymbol(input);
// Result: 'Line one\nﷺ\nLine two'
Edge cases and safety
Partial matches are ignored
Incomplete salutations won’t be replaced:
replaceSalutationsWithSymbol('sallahu said something');
// Result: 'sallahu said something' (unchanged)
replaceSalutationsWithSymbol('salam alaykum');
// Result: 'salam alaykum' (unchanged)
Already replaced text
Text with existing symbols is preserved:
replaceSalutationsWithSymbol('The Prophet ﷺ said');
// Result: 'The Prophet ﷺ said' (unchanged)
Empty strings
replaceSalutationsWithSymbol('');
// Result: ''
Non-salutation Arabic
replaceSalutationsWithSymbol('الحمد لله رب العالمين');
// Result: 'الحمد لله رب العالمين' (unchanged)
Real-world example
import { replaceSalutationsWithSymbol } from 'bitaboom';
function formatHadithText(hadith: string): string {
return replaceSalutationsWithSymbol(hadith);
}
const hadith = `
The Messenger of Allah (sallallahu alayhi wasallam) said:
"The best of you are those who learn the Qur'an and teach it."
Narrated by al-Bukhari.
The Prophet صلى الله عليه وسلم was the best of mankind.
`;
const formatted = formatHadithText(hadith);
console.log(formatted);
// Output:
// The Messenger of Allah ﷺ said:
// "The best of you are those who learn the Qur'an and teach it."
//
// Narrated by al-Bukhari.
// The Prophet ﷺ was the best of mankind.
The replaceSalutationsWithSymbol function recognizes over 130 different variations of salutations, including:
- Multiple Arabic patterns (primary, alternative, salawat, and reverse forms)
- Various Latin transliteration schemes
- Common English abbreviations and phrases
- Parenthetical and standalone forms
The function uses an efficient multi-pass approach:
- Parenthetical patterns (contextual)
- Abbreviations (exact matches)
- Latin transliterations (token-based FSM)
- Arabic patterns (token-based matching)
- English phrases
- Symbol cleanup
This order ensures accurate replacement while maintaining good performance even on large texts.
Whitespace is normalized but line breaks are preserved, so the function works correctly with both single-line and multi-line text.