SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Philadephia, PA
    1 Post(s)
    0 Thread(s)

    Question Regex help

    I'm trying to allow a person to highlight a word or phrase every time it occurs in the page they are viewing. $highlight is captured through a form on the page and specifies that word/phrase to be highlighted. All the code for the rest is fine, except I don't know enough about regex to exclude words within HTML tags from being replaced by this, messing up the pages. $content contains the HTML of the page that gets echoed after a bunch of replaces like this one to fill in variables in my templates.

    eregi_replace("$highlight","<span style=\"background: yellow\"><b>$highlight</b></span>",$content);
    If they type in the word "hidden", it'll obviously mess up any hidden input tags, for example. Does anyone know how to do this? Thanks in advance.
    Last edited by Dan Grossman; Mar 16, 2003 at 16:50.

  2. #2
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    0 Post(s)
    0 Thread(s)
    switch to preg_replace() and then see this thread:
    - Matt ** Ignore old signature for now... **
    Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
    "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR


Posting Permissions

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