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

WBOY
Release: 2016-06-13 10:17:50
Original
770 people have browsed it

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

PHP code
有110110好呀';echo preg_replace('/(img|110|b)/i', "\${1}", $str);?>
Copy after login


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


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

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

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