Regular Expression For Arabic Language

后端 未结 3 771
暗喜
暗喜 2020-11-27 16:39

I want to write a regular expression that matches each word in a sentence:

My regular expression:\"\\b(\\w+)\\b\"

Result:

相关标签:
3条回答
  • 2020-11-27 17:07

    You can do it with function to translate Aracbic Characters list, Its very simple to do.

    As Like :

    function (regexStr) {
       regexStr = replace(regexStr,"ۿ","\u0600");
       regexStr = replace(regexStr,"؀","\u06FF");
    
       return regexStr;
    }
    

    Or in another idea replacing [alf] and [ya] to see your text direction correctly

    var regexStr = "/[[alf]-[ya]]/";
    
     function (regexStr) {
       regexStr = replace(regexStr,"[alf]","\u0600");
       regexStr = replace(regexStr,"[ya]","\u06FF");
    
       return regexStr;
    }
    
    0 讨论(0)
  • 2020-11-27 17:20

    I'd suggest this :

    \p{InArabic}
    
    0 讨论(0)
  • 2020-11-27 17:28

    Try this:-

    function HasArabicCharacters(text)
    {
        var arregex = /[\u0600-\u06FF]/;
        alert(arregex.test(text));
    } 
    

    Arabic character set of list

    [\u0600-\u06ff]|[\u0750-\u077f]|[\ufb50-\ufc3f]|[\ufe70-\ufefc]
    

    Arabic script in Unicode:

    As of Unicode 6.1, the Arabic script is contained in the following blocks:

    Arabic (0600—06FF, 225 characters)
    Arabic Supplement (0750—077F, 48 characters)
    Arabic Extended-A (08A0—08FF, 39 characters)
    Arabic Presentation Forms-A (FB50—FDFF, 608 characters)
    Arabic Presentation Forms-B (FE70—FEFF, 140 characters)
    Rumi Numeral Symbols (10E60—10E7F, 31 characters)
    Arabic Mathematical Alphabetic Symbols (1EE00—1EEFF, 143 characters)
    

    Contents are taken from wikipedia - Arabic script in Unicode

    0 讨论(0)
提交回复
热议问题