Functions
isArabic(str, trimPattern?)
Returns true when all characters of str (after trimming) are in the Arabic Unicode block and match contextual Arabic letterforms.
Parameters
hasArabic(str)
Returns true when str contains at least one Arabic character.
Persian vs. Arabic
Persian uses the Arabic script plusپ چ ژ گ plus different code points for ya/kaf. Two practical consequences:
- A pure Persian string typed on a Persian keyboard also passes
isArabic— the characters all fall in U+0600–U+06FF. - A pure Arabic string fails
isPersian(default mode) only because of trim/punctuation rules; in complex mode the verdict can flip.
Edge cases
Pitfalls
isArabicis not the negation ofisPersian. Use the combined check shown above when you need a clean partition.- Arabic-Indic digits (
٠-٩) pass; Persian digits (۰-۹) pass too. For digit-level distinction, usearDigitsRegexandfaDigitsRegexfrom the Digits module.
Source
src/modules/isArabic/index.ts · Tests: test/isArabic.spec.ts