求正则匹配tab, t貌似也会匹配空格呢

WBOY
Release: 2016-06-23 14:02:58
Original
1540 people have browsed it

求正则匹配tab, \t貌似也会匹配空格呢


回复讨论(解决方案)

这么可能呢?分析如下

$s = ' 	'; //一个空格加一个制表符echo current(unpack('H*', $s)); //2009 20是空格的十六进制内码,09是Tab键的十六进制内码preg_match("/\t+/", $s, $r);echo current(unpack('H*', $r[0])); //得到 09preg_match("/ +/", $s, $r);echo current(unpack('H*', $r[0])); //得到 20preg_match("/\s+/", $s, $r);echo current(unpack('H*', $r[0])); //得到 2009
Copy after login

我的编辑器错了,都是tab键,一个tab显示的距离只有空格的宽度,晕死

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!