note 47734 deleted from function.preg-replace by tularis

From: Date: Sun, 18 Jun 2006 13:22:16 +0000
Subject: note 47734 deleted from function.preg-replace by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-114304@lists.php.net to get a copy of this message
Note Submitter: adam at releod dot com ---- In addition to pauls note. If you have a string as follows "today I went to http://www.google.com it was great" anything after the url is automatically parsed into the clickable link. Quick fix as follows <? $text = "Hello World. Today I visited http://www.google.com/ for the first time"; $text = preg_replace("/(http:\/\/(.*)\/)[\S]*/", "<a href=\\1>\\1</a> ", $text); echo $text; ?> Simply add \/ After the (.*)

« previous php.notes (#114304) next »