Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to match arabic words with reg exp? [duplicate]

I have a string like this: "سلام علیکم" which is a two word arabic phrase. I want to match first word with regular expression. If it was english I would test /^[a-zA-Z]*/. how can I do it with arabic?

like image 838
RobyJas Avatar asked Mar 17 '13 20:03

RobyJas


2 Answers

You can create a character class which will match arabic language only:

/^[\p{Arabic}]*/

Here is the full reference

like image 50
VladL Avatar answered Sep 22 '22 01:09

VladL


Arabic characters are :

'\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC'
like image 39
Mostafa Shahverdy Avatar answered Sep 22 '22 01:09

Mostafa Shahverdy