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

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

WBOY
WBOYOriginal
2016-06-13 12:51:43784browse

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


------解决方案--------------------
这么可能呢?分析如下
$s = ' 	'; //一个空格加一个制表符
echo current(unpack('H*', $s)); //2009 20是空格的十六进制内码,09是Tab键的十六进制内码

preg_match("/\t+/", $s, $r);
echo current(unpack('H*', $r[0])); //得到 09

preg_match("/ +/", $s, $r);
echo current(unpack('H*', $r[0])); //得到 20

preg_match("/\s+/", $s, $r);
echo current(unpack('H*', $r[0])); //得到 2009
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