How can I exclude the regular expression & lt; br & gt; PHPcode & lt ;? Php $ str = 'IMG my B has 110www & lt; br & gt; has 110110 hao'; echopreg_replace ('/(img | 110 | B)/I', & quot; & lt; B & gt ;\1 {1} & lt;/how to exclude a regular expression
PHP code
110110 OK '; echo preg_replace ('/(img | 110 | B)/I ',"\ $ {1}", $ Str);?>
The purpose is to display the specified characters in bold. how can this problem be ruled out?
, Do not let
Bold.
------ Solution --------------------
Echo preg_replace ('/(img | 110 | B \ B)/I ',"
\ $ {1}", $ Str );
Or
Echo preg_replace ('/(img | 110 | B (?! R)/I ',"
\ $ {1}", $ Str );
------ Solution --------------------
?! R
------ Solution --------------------
PHP code
'/(?
------ Solution --------------------
If you need to consider the complex points, the regular expression is slightly more complex. pay attention to the img, 110, B in the html tag of the tag.
PHP code
$ Str = 'I img I B have 110www
110110 OK '; echo preg_replace ('#(? = [^>] * (? = <| $) (Img | 110 | B) # is ','\ 1', $ Str );