Regular Expression Arabic characters and numbers only

moujtahed picture moujtahed · Apr 19, 2015 · Viewed 49.4k times · Source

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 only Arabic characters while I need Arabic characters, Spaces and Numbers.

Answer

Kasravnd picture Kasravnd · Apr 19, 2015

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 numbers :

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