Home >Backend Development >PHP Tutorial >Yii2中有一段正则,没看懂,'/[=s—–-]+/u'

Yii2中有一段正则,没看懂,'/[=s—–-]+/u'

WBOY
WBOYOriginal
2016-06-06 20:22:411082browse

<code>$string = preg_replace('/[=\s—–-]+/u', $replacement, $string);</code>

=\s???

  • \s后面三个横杠长短不一,都是什么?

  • =开头是什么意思?

  • 这段正则代表什么意思? 

回复内容:

<code>$string = preg_replace('/[=\s—–-]+/u', $replacement, $string);</code>

=\s???

  • \s后面三个横杠长短不一,都是什么?

  • =开头是什么意思?

  • 这段正则代表什么意思? 

三个横线分别是三种连接号:\u2014\u2013\x2D= 就是匹配等号;这段正则就是用于替换等号、空白字符和上述三种连接号(猜测是匹配分割线之类?)。

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