regexunicodestring-matching

Regular Expression Arabic characters and numbers only


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

Numbers are not required to be in Arabic.

I found the following expression:

^[\u0621-\u064A]+$

which accepts only Arabic characters, while I need Arabic characters, Spaces and Numbers.


Solution

  • Just add 1-9 (in Unicode format) to your character-class:

    ^[\u0621-\u064A0-9 ]+$
    

    OR add \u0660-\u0669 to the character-class which is the range of Arabic-Indic numbers :

    ^[\u0621-\u064A\u0660-\u0669 ]+$