How is the filter input for a Persian character?

I need a filter input only for Farsi, I think that regex with filter_input()is a good idea, but I don’t know how to solve this problem, I’m looking for it, but I don’t find sth like \ p {Arabic} for Farsi or Persian character, with on the other hand, this is possible with Unicode , but I have no idea about its regular expression.

+5
source share
1 answer

This should work:

preg_match("(^[\x{0600}-\x{06FF}]*$)", 'فارسی');

And also you can use all these forms for the Persian language:

Persian alphabet

فارسی

/^([\x{0600}-\x{06EF}])+$/

Persian numbers

1234567890

/^([\x{06F0}-\x{06F9}])+$/

Persian plain text with space and half-space

اگر زمان و مکان در اختیار ما بود, 10 سال پیش از طوفان نوح عاشقت میشدم

/^([\x{0600}-\x{06FF}| |\x{200C}])+$/
+8
source

All Articles