“Cara Memeriksa Teks Hanya memiliki teks Arab” Kode Jawaban

Cara Memeriksa Teks Hanya memiliki teks Arab

public static boolean isProbablyArabic(String s) {
    for (int i = 0; i < s.length();) {
        int c = s.codePointAt(i);
        if (c >= 0x0600 && c <= 0x06E0)
            return true;
        i += Character.charCount(c);            
    }
    return false;
  }
code fighter

Cara Memeriksa Teks Hanya memiliki teks Arab

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
code fighter

Jawaban yang mirip dengan “Cara Memeriksa Teks Hanya memiliki teks Arab”

Pertanyaan yang mirip dengan “Cara Memeriksa Teks Hanya memiliki teks Arab”

Lebih banyak jawaban terkait untuk “Cara Memeriksa Teks Hanya memiliki teks Arab” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya