正则表达式 - 请教PHP中这则正则`#x{00a0}#siu`是什么意思?

WBOY
Release: 2016-06-06 20:32:33
Original
1649 people have browsed it

在代码中发现的,不太理解,请高手分析下

<code>$filename = preg_replace( "#\x{00a0}#siu", ' ', $filename );
</code>
Copy after login
Copy after login

回复内容:

在代码中发现的,不太理解,请高手分析下

<code>$filename = preg_replace( "#\x{00a0}#siu", ' ', $filename );
</code>
Copy after login
Copy after login

x{00a0} 是UTF-8的 Non-breaking space,这个空格和单纯用键盘上的space键敲出来的还不一样,甚至肉眼都无法分辨出来,如果你在编辑器里面查找,就可以发现问题。

<code>$filename = preg_replace( "/#\x{00a0}#siu/u", ' ', $filename );
</code>
Copy after login

这是Wiki 上关于 Non-breaking space 的介绍,其中也有怎么输出这个字符的方法。
https://en.wikipedia.org/wiki/Non-breaking_space

想把00a0这个字符替换成空格

00a0是NON-BREAKING-SPACE,也就是&nbsp

试了一下似乎因为有u,工作不太正常

Related labels:
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