note 52671 added to function.preg-replace
| From: | h at matfyz dot cz | Date: | Mon, 09 May 2005 12:04:34 +0000 |
| Subject: | note 52671 added to function.preg-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-89152@lists.php.net to get a copy of this message | ||
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);
----
Manual Page -- http://www.php.net/manual/en/function.preg-replace.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+52671
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+52671&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+52671&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+52671&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+52671&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+52671&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+52671&report=yes
Search -- http://master.php.net/manage/user-notes.php