[^ A-zA-Z0-9u4e00-u9fa5s] I use this matching symbol. in php, preg_replace always reports an error. how can this problem be solved? [^ A-zA-Z0-9 \ u4e00-\ u9fa5 \ s] please enlighten me
Reply to discussion (solution)
/[^ A-zA-Z0-9 \ x {4e00}-\ x {9fa5} \ s]/u
It must be UTF-8 encoded.
However, if it is UTF-8 encoded, \ w will be able to match Chinese characters. why bother?
What is the error message?
What is the error message?
I matched all the characters. php pre_place cannot match this regular expression. it is depressing!
Header ('content-type: text/html; charset = utf-8 '); $ s = 'Asa-de + Chinese 123 '; $ p = '/[^ a-zA-Z0-9 \ x {4e00}-\ x {9fa5} \ s]/U'; echo preg_replace ($ p, '', $ s ); // asade Chinese 123 echo preg_replace ('/[^ \ w \ s]/U', '', $ s); // asade Chinese 123
What is the error message?
WARNING: PREG_MATCH_ALL () [FUNCTION.PREG-MATCH-ALL]: compilation failed: pcre does not support \ L, \ L, \ N {NAME}, \ U, OR \ u at offset 15 in c: \ WAMP \ WWW \ INDEX_MULTI.PHP ON
Header ('content-type: text/html; charset = utf-8 '); $ s = 'Asa-de + Chinese 123 '; $ p = '/[^ a-zA-Z0-9 \ x {4e00}-\ x {9fa5} \ s]/U'; echo preg_replace ($ p, '', $ s ); // asade Chinese 123 echo preg_replace ('/[^ \ w \ s]/U', '', $ s); // asade Chinese 123
Although I still don't know where I am wrong, I can use a tool to match it, but your method is successful, there is no error, learn, thank you
So far, php regular expressions do not support \ u4e00.
So you are not wrong.
So far, php regular expressions do not support \ u4e00.
So you are not wrong.