Ask a regular expression and how to exclude it <br>

Source: Internet
Author: User
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 );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.