Regular expression: only Chinese characters and letters in the string are retained. Regular expression: only Chinese characters and letters in the string are retained, unicodepreg_replace ('# [^ a-z \ u4e00-\ u9fbb] # I', & nbsp; '', & nbsp; normalization expression: only Chinese characters and letters in the string are retained.
Regular expression: only Chinese characters and letters in the string are retained.
------ Solution --------------------
Unicode required
Preg_replace ('# [^ a-z \ u4e00-\ u9fbb] # I', '', $ string)
It is more complicated to separate full-angle symbols and Chinese characters under GBK.
------ Solution --------------------
If it is not UTF-8 encoded, transcoding is required.
$ S = '# $ % ^ 4sdfg3 haha sdfgtpd $ #%# $ %
?> <,.~! Tt method ';
Echo preg_replace ('/[\ d \ W _]/U', '', $ s );
Sdfg haha sdfgfdgAShtt method
Your #1 supplement is inconsistent with the original post's requirements
Echo preg_replace ('/[\ d \ W_a-z]/iu', '', $ s );
Haha method