note 57741 added to function.preg-replace
| From: | NickBullock-SafireX at osu1 dot php dot net | Date: | Wed, 12 Oct 2005 23:24:26 +0000 |
| Subject: | note 57741 added to function.preg-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-96923@lists.php.net to get a copy of this message | ||
An improved and corrected version of a function I put together to process HTML strings from a
database or output buffer.
<?
function linkScan($string1)
{
$pattern1 = "/(?<![\\/\\d\\w])(http:\\/\\/)?([\\w\\d\\-]+)
((\\.([\\w\\d\\-])+){2,})([\\/\\?\\w\\d\\.\\-_&=+%]*)?/i";
$replace1 = "<a href=\\"http://$2$3$6\\"
target=\\"popup\\">$0</a>";
$string2 = preg_replace($pattern1,$replace1,$string1);
$pattern2 = "/[\\d\\w\\.\\-_]+@[\\d\\w\\-_\\.]+?
\\.[\\w]{2,3}(\\.[\\w]{2,3})?/i";
$replace2 = "<a href=\\"mailto:$0\\">$0</a>";
$string3 = preg_replace($pattern2,$replace2,$string2);
return $string3;
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.preg-replace.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+57741
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+57741&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+57741&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+57741&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+57741&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+57741&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+57741&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+57741&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+57741&report=yes
Search -- http://master.php.net/manage/user-notes.php