I want Regular Expression to accept only Arabic characters, Spaces and Numbers.
Numbers are not required to be in
With a lot of try and edit i got this for Persian names:
[گچپژیلفقهمو ء-ي]+$
In PHP, use this:
preg_replace("/\p{Arabic}/u", 'x', 'abc123ابت');// will replace arabic letters with "x".
Note: For \p{Arabic}
to match arabic letters, you need to pass u
modifier (for unicode) at the end.
^[\u0621-\u064Aa-zA-Z\d\-_\s]+$
This regex must accept Arabic letters,English letters, spaces and numbers
[\p{IsArabic}-[\D]]
An Arabic character that is not a non-digit
you can use [ء-ي] it worked for me in javascript Jquery forme.validate rules
for my example I want to force user to insert 3 characters
[a-zA-Zء-ي]
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 ]+$