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), and also looks pretty? Nik p.s. apologies for bodging the In-Reply-To -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php