Re: dynamic link converter

From: Date: Thu, 06 Mar 2003 10:26:37 +0000
Subject: Re: dynamic link converter
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-138445@lists.php.net to get a copy of this message
thanks heaps mate http://electroteque.dyndns.org:1023/benchmark/preg.phps here it is with email hyperlinking aswell "Nik Makepeace" <nik@nikmakepeace.com> wrote in message news:1046919812.2910.747.camel@gruyere... > On Thu, 2003-03-06 at 05:49, electroteque wrote: > > hi there i am trying tom preg_replace on a string enclosed in brackets to > > denote a dynamic link > > This works, if I understand you correctly: > > <?php > $message = "[http://www.eletroteque.dyndns.org/index_html.php|Eletroteque Multimedia]"; > > echo $message = preg_replace( > "/\[((http(s?):\/\/)|(www\.))([\w\.]+)([\/\w+\.]+)\|([\s\w\.]+)\b\]/i", > "<a href=\"http\\3://\\4\\5\\6\" > target=\"_blank\">\\7</a>", > $message > ); > ?> > > But wouldn't it be easier just to do use a pattern like this > > "/\[([^|]+)\|([^\]]+)/" > > which gets everything between [ and | (the URI) and | and ] (the link > name)? > > Nik >

« previous php.general (#138445) next »