Regular Expression Arabic characters and numbers only

后端 未结 11 943
梦毁少年i
梦毁少年i 2020-11-27 02:44

I want Regular Expression to accept only Arabic characters, Spaces and Numbers.

Numbers are not required to be in

相关标签:
11条回答
  • 2020-11-27 03:23

    You can use:

    ^[\u0621-\u064A\s\p{N}]+$
    

    \p{N} will match any unicode numeric digit.

    To match only ASCII digit use:

    ^[\u0621-\u064A\s0-9]+$
    

    EDIT: Better to use this regex:

    ^[\p{Arabic}\s\p{N}]+$
    

    RegEx Demo

    0 讨论(0)
  • 2020-11-27 03:23
    function HasArabicCharacters(string text)
    
    {
    
        var regex = new RegExp(
    
            "[\u0600-\u06ff]|[\u0750-\u077f]|[\ufb50-\ufc3f]|[\ufe70-\ufefc]");
    
        return regex.test(text);
    }
    
    0 讨论(0)
  • 2020-11-27 03:24

    The posts above include much more than arabic (MSA) characters, it includes persian, urdu, quranic symbols, and some other symbols. The arabic MSA characters are only (see Arabic Unicode)

    [\u0621-\u063A\u0641-\u0652] 
    
    0 讨论(0)
  • 2020-11-27 03:25

    Simple, use this code:

    ^[؀-ۿ]+$
    

    This works for Arabic/Persian even numbers.

    0 讨论(0)
  • 2020-11-27 03:27

    use this

    [\u0600-\u06FF]
    

    it worked for me on visual studio

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