#1
  1. Full Access
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jun 2000
    Location
    London, UK
    Posts
    2,019
    Rep Power
    16
    Does anyone know of a regular expression that will turn email addresses and URL's into links to themselves? I was thinking of something like this, really, to avoid problems with full-stops being tagged onto the end of the actual link:

    <link>http://www.site.com</link>
    <link>don@site.com</link>

    Or I could use the square-brackets instead of angle-brackets, which is probably better as I intent to strip out any other HTML tags.

    Does anyone know what kind of regex I should use for this, and how would it be implemented in the PHP? Thanks.

    --------------------------------------------
    Alex
    (http://www.alex-greg.co.uk)
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Niteroi, RJ, Brazil
    Posts
    30
    Rep Power
    14
    I didn't understood what you wanted, but try this:

    // Emails

    eregi_replace("<a href="mailto:", "<link>", $string);

    // Links

    eregi_replace("<a href="", "<link>", $string);

    // General (closing tags)

    eregi_replace("">.*</a>", "</link>", $string);

    Where $string a variable containing the information. I think this should work. I'm not a regex expert but try this... Can anyone please correct any errors? Thanks!

    Excuse my english please!

    ------------------
    Eduardo Teixeira Cardoso
    PHP Programmer from Brazil
    idnotfound@vircio.com.br

    [This message has been edited by IdNotFound (edited August 14, 2000).]

    [This message has been edited by IdNotFound (edited August 14, 2000).]
  4. #3
  5. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15
    Alex,

    here is a useful discussion for you
    http://www.devshed.com/Talk/Forums/F...ML/002352.html

    i don't know wether you are looking for samething or not.




    ------------------
    SR -
    webshiju.com
    www.jobxyz.com-IT Career Portal
    ezipindia.com--WebStudio


    "The fear of the LORD is the beginning of knowledge..."

IMN logo majestic logo threadwatch logo seochat tools logo