I am trying to take a UTF-8 string that looks something like:
&q| 艝隭)R墢Lq28}徫廵g'Y鑽妽踒F
and strip out everything except the Chinese characters they are hex 4E00-9FA5 and I would like to keep only those characters in the string. I have tried taking this line that leaves only valid US characters:
preg_replace('/[^\x20-\x7E]/', '', $str);
to this:
preg_replace('/[^\x4E开发者_运维问答00-\x9FA5]/u', '', $str);
but it outputs nothing....am I missing something? I am not very good with regular expressions
You were very close!
preg_replace('/[^\x{4E00}-\x{9FA5}]/u', '', $str);
精彩评论