I found this regular expression for Arabic letters but it is also allowing numbers with letters. How can I change it to let it allow letters only ?
/[\u0600-\u06FF]/
Use the count option to check if a string includes Arabic characters. It has full support.
The regex [0-9] matches single-digit numbers 0 to 9. [1-9][0-9] matches double-digit numbers 10 to 99. That's the easy part. Matching the three-digit numbers is a little more complicated, since we need to exclude numbers 256 through 999.
To match any character except a list of excluded characters, put the excluded charaters between [^ and ] . The caret ^ must immediately follow the [ or else it stands for just itself.
Probably you'd have to check what range the numbers match and exclude it (formally not include in brackets expression).
Here I've found another helpful source.
I'd suggest this for only letters
/[\u0600-\u065F\u066A-\u06EF\u06FA-\u06FF]/
as this matches arabic digits only
/[\u0660-\u0669\u06F0-\u06F9]/
Edit:
I've found that there are two ranges for arabic and arabic-indic digits in unicode.
If you need a regex to match a line just then, when it contains arabic letters and numbers - use this:
/^[\u0600-\u06FF]*$/
If you want to also discourage arabic digits - use this:
/^[\u0600-\u065F\u066A-\u06EF\u06FA-\u06FF]*$/
If you want to match a substring, not only a whole line, use this:
/\b[\s\u0600-\u065F\u066A-\u06EF\u06FA-\u06FF]*\b/
I tried all solutions provided here, nothing worked, finally one solution worked for me for Arabic letters only
^[\u0621-\u064A\040]+$
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With