Home  >  Article  >  Backend Development  >  PHP:这段正则是验证啥的,看不懂?该怎么处理

PHP:这段正则是验证啥的,看不懂?该怎么处理

WBOY
WBOYOriginal
2016-06-13 12:24:29933browse

PHP:这段正则是验证啥的,看不懂?
这段正则是验证啥的,看不懂?
/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|\xe0[\xa0-\xbf][\x80-\xbf]|[\xe1-\xef][\x80-\xbf][\x80-\xbf]|\xf0[\x90-\xbf][\x80-\xbf][\x80-\xbf]|[\xf1-\xf7][\x80-\xbf][\x80-\xbf][\x80-\xbf]/

求教!!!
------解决思路----------------------
验证是否为 utf-8 字符

其中
[\x01-\x7f] 单字节 utf-8
[\xc2-\xdf][\x80-\xbf] 2字节 utf-8
\xe0[\xa0-\xbf][\x80-\xbf] 3字节 utf-8
[\xe1-\xef][\x80-\xbf][\x80-\xbf] 3字节 utf-8
\xf0[\x90-\xbf][\x80-\xbf][\x80-\xbf] 4字节 utf-8
[\xf1-\xf7][\x80-\xbf][\x80-\xbf][\x80-\xbf] 5字节 utf-8

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn