Home >Backend Development >PHP Tutorial >正则匹配不包含某字符串的字符串

正则匹配不包含某字符串的字符串

WBOY
WBOYOriginal
2016-06-06 20:33:071311browse

除了前面两个连续&nbsp<br>,其他的<br>全部匹配,请教正则应该怎么写?

<code>  <br>  #不匹配
</code>

回复内容:

除了前面两个连续&nbsp<br>,其他的<br>全部匹配,请教正则应该怎么写?

<code>  <br>  #不匹配
</code>

/(?)+/

试试这个:/  <br>((<br>)*)/

<code>var matches = '  <br><br><br><br>'.match(/  <br>((<br>)*)/);
// matches[1] => "<br><br><br>"
</code>

b.t.w, 偶的正则比较水,坐等楼下大牛解答

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