escapeRegex
Escape a string so it can be safely embedded into a RegExp source.Any string
string - Escaped string safe for use in regular expressions.
makeDiacriticInsensitiveRegex
Build a diacritic-insensitive, tatweel-tolerant RegExp for Arabic text matching. Features:- Optional character equivalences: ا
أإآ, ةه, ى~ي - Optional tolerance for tatweel between characters
- Optional diacritic-insensitivity (by inserting a diacritics class after each char)
- Optional flexible whitespace (needle whitespace becomes
\s+)
The Arabic text to match
Configuration options for the regex pattern
MakeRegexOptions
Character equivalences to allow. Default:
{ alif: true, taMarbutahHa: true, alifMaqsurahYa: true }alif(boolean): Treat ا/أ/إ/آ as equivalent. Default: truetaMarbutahHa(boolean): Treat ة/ه as equivalent. Default: truealifMaqsurahYa(boolean): Treat ى/ي as equivalent. Default: true
Allow tatweel between letters (tolerate decorative elongation)
Ignore diacritics by inserting a
DIACRITICS_CLASS* after each letterTreat any whitespace in the needle as
\s+ for flexible matchingRegExp flags to use
RegExp - A RegExp matching the needle with the desired tolerances.
removeAllTags
Remove simple HTML/XML-like tags from a string. This is intentionally lightweight and does not attempt to parse HTML; it simply drops substrings that look like<...>.
Input string
string - String with tags removed.