#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Posts
    2
    Rep Power
    0

    Question PHP question re. reg. exps.


    Hello;

    I have a question.

    I'm building a CMS, and one of the features I want it to have is to automatically link to pages that exists. F.ex. is a page called "Download" exists, every occurrance of the word "Download" in any page should be converted to a link to the "Download" page.

    I have the basics working, but I have one problem.

    EVERY occurrance of "Download" (still using the same example) is being converted to "<A HREF=".?page=Download">Download</A>", which is good, but I don't want "<IMG SRC=DOWNLOAD.GIF>" (f.ex.) to be converted (to "<IMG SRC=<A HREF=".?page=Download">Download</A>.GIF>" )

    How can I set up a regexp to do this for me? So only the words in the 'visible' (in the browser) HTML are converted (everything outside tags < and > ).

    What I use now is:

    PHP Code:
    $content=eregi_replace("([^[:alnum:]])($file)([^[:alnum:]])","\\1<A HREF=\".?page=$file\" style=\"text-decoration:underline;\">\\2</A>\\3",$content); 
    (where $file is the name of a page I'm looking for)

    I hope someone can help (I'm not very good at regular expressions).
    Last edited by jfitie; December 9th, 2003 at 09:35 AM.
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Posts
    2
    Rep Power
    0
    anyone know how to do it?

IMN logo majestic logo threadwatch logo seochat tools logo