Re: Some RegEx help please

From: Date: Thu, 14 Sep 2000 23:10:11 +0000
Subject: Re: Some RegEx help please
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-16860@lists.php.net to get a copy of this message
Actually, I guess I left something out, but before I dive into that, this won't work if it's the first thing in a string because of the space at the begin of the search pattern... BUT, this won't quite work for me because this interferes with legitimate URLS in the given text. If my text is as follows, I only want the URLs that are not already surrounded by an <A HREF=""> tag to be converted $cBlah = "this <A HREF="http://www.somepage.com">tag</A> would not convert, but this one http://www.someotherpage.com would convert..."; And the same thing applies to email addresses as well..... At 03:34 PM 9/14/00, James Atkinson wrote:
This should do it, I found it at www.phpwizard.net function make_clickable($text) {
        $ret = eregi_replace(" ([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])", "<a href=\"\\1://\\2\\3\" target=\"_blank\" target=\"_new\">\\1://\\2\\3</a>", $text);
        $ret = eregi_replace(" (([a-z0-9_]|\\-|\\.)+@([^[:space:]]*)([[:alnum:]-]))", "<a href=\"mailto:\\1\" target=\"_new\">\\1</a>", $ret);
        return($ret);
} It'll do email address's and URLS.
On Thu, 14 Sep 2000, Joe Sheble aka Wizaerd wrote:
I know I'm real light on the regular expression stuff, and it's my own fault, but I'm working under a fairly heavy deadline, otherwise I'd just find the answer myself. I need a regular expression that finds all web URLs in a given string and converts it to a clickable link. All URLs, even including GET based parameters as well. COuld somebody help me out with this, or point to me a place where I could find such a beast? I've looked on some of the various PHP resources on the net, but I never know what to search for when searching for such a script...
Joseph E. Sheble aka Wizaerd ============================= Wizaerd's Realm http://www.wizaerd.com =============================

« previous php.general (#16860) next »