note 52671 deleted from function.preg-replace by didou

From: Date: Sun, 23 Apr 2006 22:51:06 +0000
Subject: note 52671 deleted from function.preg-replace by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-109228@lists.php.net to get a copy of this message
Note Submitter: h at matfyz dot cz ---- Regular expression for replacing urls by anchor. Examples: www.google.com -> <a href="http://www.google.com" title="www.google.com">www.google.com</a> http://www.google.com -> <a href="http://www.google.com" title="http://www.google.com">www.google.com</a> https://www.google.com -> <a href="https://www.google.com" title="https://www.google.com">www.google.com</a> $text = preg_replace( "((http)+(s)?:(//)|(www\.))((\w|\.|\-|_)+)(/)?(\S+)?i", "<a href=\"http\\3://\\5\\6\\8\\9\" title=\"\\0\">\\5\\6</a>", $text);

« previous php.notes (#109228) next »