I want Regular Expression to accept only Arabic characters, Spaces and Numbers.
Numbers are not required to be in
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
function HasArabicCharacters(string text)
{
var regex = new RegExp(
"[\u0600-\u06ff]|[\u0750-\u077f]|[\ufb50-\ufc3f]|[\ufe70-\ufefc]");
return regex.test(text);
}
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]
Simple, use this code:
^[-ۿ]+$
This works for Arabic/Persian even numbers.
use this
[\u0600-\u06FF]
it worked for me on visual studio