Regular Expressions in PHP | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 8

Regular Expressions in PHP

I need to Regular Expressions support all Persian character. how write it? My code in PHP چطور می‌توانم عبارت با قائده‌ای بنویسم که تمام عبارت های فارسی رو قبول کنه. حتی نیم فاصله رو؟ چند تا پیدا کردم هر کدوم مشکلی داشت.

28th Dec 2018, 3:57 AM
Seyyed Mohammad Mirsalehi Tarki
Seyyed Mohammad Mirsalehi Tarki - avatar
2 Answers
+ 9
$string = preg_replace("/[^ الف-ی]/i", "", $string); This will remove all characters except Persian chars 
28th Dec 2018, 4:12 AM
Ahlin Chan
Ahlin Chan - avatar
+ 1
Your code doesn't support Persian and displaying "??????" ? Try adding this: header('Content-Type: text/html; charset=UTF-8');
15th Mar 2019, 7:43 AM
Mykhailo Stetsiuk
Mykhailo Stetsiuk - avatar