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

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

WBOY
Release: 2016-06-06 20:22:41
Original
1081 people have browsed it

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

=\s???

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

  • =开头是什么意思?

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

回复内容:

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

=\s???

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

  • =开头是什么意思?

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

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

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