Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    Regular Coder
    Join Date
    Jan 2006
    Finland, Hollola
    Thanked 0 Times in 0 Posts

    Question Removing font tags inside <!-- --> comments with PCRE

    Hi. Like I said in the title. I need to remove <font color="#xxxxxx">blah</font> text instead off getting rid of anything else like the blah.

    Here's my HTML code:
    &lt;<font color="#800080">script</font> type=<font color="#3A6EA5">&quot;text/javascript&quot;</font>&gt;<font color="#008000">&lt;!--
    <br />
    google_ad_client = <font color="#3A6EA5">&quot;pub-2364887827571271&quot;</font>;
    google_ad_height = 90;
    <br />
    google_color_border = <font color="#3A6EA5">&quot;E1EBFF&quot;</font>;
    <br />
    google_color_text = <font color="#3A6EA5">&quot;677695&quot;</font>;
    <br />
    //--&gt;</font>&lt;/<font color="#800080">script</font>&gt;
    <br />
    &lt;<font color="#800080">script</font> type=<font color="#3A6EA5">&quot;text/javascript&quot;</font>
    <br />
    Here's a sample:
    text text text <!-- this text is not going to be removed but the tag: <font color="#xxxxxxx">this will stay</font> tag will be removed...-->
    This tag wont be removed because its outside the html comments tags <font color="#xxxxxx">sdg</font>
    My code so far:
    PHP Code:
    $text preg_replace("/(&lt;!--)(.*?)(<font color=\"#[\d\w]{6}\">)(.*?)(<\\/font>)(.*?)(--&gt;)/si","\\1\\2\\4\\6\\7",$text); 
    EDIT: I am making a HTML code highlightor and it put font color tags inside comment tags and it should not do that because all text inside comments tags will be the same color...
    Last edited by kaisellgren; 11-08-2006 at 10:03 PM.
    PHP 5 & MySQL 5 (Y)


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts