Re: Some RegEx help please

From: Date: Thu, 14 Sep 2000 22:34:56 +0000
Subject: Re: Some RegEx help please
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-16848@lists.php.net to get a copy of this message
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... > > thanx! > 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. -- James Atkinson ----------------------------------------------------------------- James Atkinson 100world Technical Developer 512-1529 West 6th Avenue phone: +1-604-637-8122 Vancouver, BC, V6J 1R1 fax: +1-604-742-1770 Canada email: james.atkinson@100world.com http://www.100world.com +---------------------------------------------------------------+ | This message may contain confidential and/or privileged | | information. If you are not the addressee or authorized to | | receive this for the addressee, you must not use, copy, | | discolse or take any action based on this message or any | | information herein. If you have received this message in | | error, please advise the sender immediately by reply e-mail | | and delete this message. Thank you for you cooperation | +---------------------------------------------------------------+

« previous php.general (#16848) next »