PHP Regex to match group of Arabic Keywords

82 Views Asked by At

i have this,

/(?<!\pL)(أحمد|محمد|حسن|محسن|على|حاتم|مصطفى)(?!\pL)/iu

it match just one word, maybe the first one, take a look here (https://regex101.com/r/3CEPHo/1)

how can i make it match all, and is there best practice in this? this words in the group may exceed 2000 work, is matching it with regex right?

1

There are 1 best solutions below

0
On

You can use this regular expression to match all Arabic characters including spaces

For PHP

/\p{Arabic}/u

Or this (language independent):

/[ا-ي]/g