Home > Backend Development > PHP Tutorial > PHP:这段正则是验证啥的,看不懂?

PHP:这段正则是验证啥的,看不懂?

WBOY
Release: 2016-06-23 13:26:47
Original
1030 people have browsed it

这段正则是验证啥的,看不懂?
/[\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

验证是否为 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



奥,受教了,谢了!
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template