Re: finding a link in large text blob

From: Date: Thu, 06 Dec 2001 21:24:03 +0000
Subject: Re: finding a link in large text blob
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-14848@lists.php.net to get a copy of this message
mmm... as sooo hard to find this... i looked on PHP.net! shock horror. & tah do :) its done :) sluderitz@yahoo.de 28-Jun-2001 04:30 I use this function to make hyperlinks from user submitted URL's (useful for notice boards, etc.): $message = preg_replace("/((http(s?):\/\/)|(www\.))([\w\.]+)/i", "<a href=\"http$3://$4$5\" target=\"_blank\">$2$4$5</a>", $message); ----- Original Message ----- From: "Terry Romine" <eatrom@blazing-trails.com> To: <php-db@lists.php.net> Sent: Friday, December 07, 2001 7:08 AM Subject: [PHP-DB] finding a link in large text blob > Is everyone ignoring me?? This is the third time I have asked for > assistance on this... > > Is there an easy way (say using eregi_replace) to find a link reference > in a blob of text and add the <a href> anchor around it? Something like: > > "text has a link to a website at > http://www.whatever.com/mydirectory/mypage.html ..." > > and converts it to > > "text has a link to a website at <a > href='¬ > EOVȃUxÈhttp://www.whatever.com/mydirectory/mypage.html'>website</a> > ..." > > My thoughts are that I should be able to do something like a > eregi_replace, finding any occurances of http:// and trapping > all > non-space characters following it to convert to the anchor. But what > about multiples? How do I rebuild the text with the substitute strings? > > Thanks in advance > > Terry >

« previous php.db (#14848) next »