📅  最后修改于: 2022-03-11 14:58:36.787000             🧑  作者: Mango
const isItAllArabic =s=>(!/[^\u0600-\u06FF ]/.test(s));
//======================================================
// Test if a string has only Arabic Characters
// Latin punctuation marks and number exist in Arabic
// Strings as there mostly used due to some not existing
// in Arabic Unicode letter.
//
// Output: Return true/false
//======================================================
const isItAllArabic =s=>(!/[^\u0600-\u06FF\u0020-\u0040\u005B-\u0060\u007B-\u007E]/.test(s));
//======================================================
console.log(isItAllArabic("Ù
ØسÙ")); // true. All Arabic text
console.log(isItAllArabic("(Ù
ØسÙ)")); // true. Symbols () ignored
console.log(isItAllArabic("Ù
ØسÙ/Ù
ØÙ
د! ÙعÙÙ")); // true. Punctuations and Symbols ignored
console.log(isItAllArabic("Ù
Øس٠123")); // true as numbers are ok
console.log(isItAllArabic("Ù
Øس٠mohsen")); // false because latin chars
console.log(isItAllArabic("mohsen")); // false