Home >Backend Development >PHP Tutorial >求正则匹配tab, t貌似也会匹配空格呢

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

WBOY
WBOYOriginal
2016-06-23 14:02:581598browse

求正则匹配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

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

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
Previous article:PHP mail的问题Next article:如何采集防采集的网站