Home >Backend Development >PHP Tutorial >问个正则表达式,如何排除<br>

问个正则表达式,如何排除<br>

WBOY
WBOYOriginal
2016-06-13 10:17:50823browse

问个正则表达式,怎么排除

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><?php $str = 'img我b有110www<br>有110110好呀';echo preg_replace('/(img|110|b)/i', "<b>\${1}</b>", $str);?>


目的是指定的字符粗体显示,怎么排除
,不让
粗体显示。


------解决方案--------------------
echo preg_replace('/(img|110|b\b)/i', "\${1}", $str);

echo preg_replace('/(img|110|b(?!r))/i', "\${1}", $str);

------解决方案--------------------
?!r
------解决方案--------------------
PHP code
'/(?<font color="#e78608">------解决方案--------------------</font><br>如果你需要考虑复杂点的情况,正则式就稍微复杂点,注意标签html标签内的img,110,b<br>
PHP code
$str = '<img  src="img/110/b.jpg" alt="问个正则表达式,如何排除<br&gt" >我img我b有110www<br>有110110好呀';echo preg_replace('#(?=[^>]*(?=\1',$str);<div class="clear">
                 
              
              
        
            </div>
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