Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How filter input for Farsi character? [duplicate]

Tags:

regex

php

I want filter input just for Farsi, i think regular expression with filter_input() is a good idea but i dont know how solve this problem, I've search but i don't find sth like \p{Arabic} for Farsi or Persian character in the other hand it can be possible with Unicode but i've no idea about its regular expression.

like image 362
user1695063 Avatar asked Mar 02 '13 19:03

user1695063


Video Answer


1 Answers

This should work :

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

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

Persian Alphabet

فارسی

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

Persian Numbers

۱۲۳۴۵۶۷۸۹۰

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

Persian simple text with space and half-space

اگر زمان و مکان در اختیار ما بود، ۱۰ سال پیش از طوفان نوح عاشقت می‌شدم

/^([\x{0600}-\x{06FF}| |\x{200C}])+$/
  • ref
like image 118
Mehdi Hosseini Avatar answered Sep 22 '22 02:09

Mehdi Hosseini