note 79204 added to function.preg-replace
| From: | t3k at osu1 dot php dot net | Date: | Thu, 15 Nov 2007 15:32:29 +0000 |
| Subject: | note 79204 added to function.preg-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-132306@lists.php.net to get a copy of this message | ||
Mac's post from 08-Oct-2007 04:18 inadvertently left out the '=' part of the query
string. I've added the '=' and copied his method (modified from Iasmin's) here:
<?php
function hyperlink($text) {
// match protocol://address/path/file.extension?some=variable&another=asf%
$text = preg_replace("/\s([a-zA-Z]+:\/\/[a-z][a-z0-9\_\.\-]*
[a-z]{2,6}[a-zA-Z0-9\/\*\-\?\&\%\=]*)([\s|\.|\,])/i",
" <a href=\"$1\" target=\"_blank\">$1</a>$2",
$text);
// match www.something.domain/path/file.extension?some=variable&another=asf%
$text = preg_replace("/\s(www\.[a-z][a-z0-9\_\.\-]*
[a-z]{2,6}[a-zA-Z0-9\/\*\-\?\&\%\=]*)([\s|\.|\,])/i",
" <a href=\"http://$1\"
target=\"_blank\">$1</a>$2", $text);
// match name@address
$text = preg_replace("/\s([a-zA-Z][a-zA-Z0-9\_\.\-]*[a-zA-Z]*
\@[a-zA-Z][a-zA-Z0-9\_\.\-]*[a-zA-Z]{2,6})([\s|\.|\,])/i",
" <a href=\"mailto://$1\">$1</a>$2", $text);
return $text;
}
?>
PS - please note that the line breaks and spaces/tabs in the method's regular expressions need
to be removed before using it.
----
Server IP: 212.199.163.191
Probable Submitter: 79.182.170.172 (proxied: 79.182.170.172)
----
Manual Page -- http://www.php.net/manual/en/function.preg-replace.php
Edit -- https://master.php.net/note/edit/79204
Del: integrated -- https://master.php.net/note/delete/79204/integrated
Del: useless -- https://master.php.net/note/delete/79204/useless
Del: bad code -- https://master.php.net/note/delete/79204/bad+code
Del: spam -- https://master.php.net/note/delete/79204/spam
Del: non-english -- https://master.php.net/note/delete/79204/non-english
Del: in docs -- https://master.php.net/note/delete/79204/in+docs
Del: other reasons-- https://master.php.net/note/delete/79204
Reject -- https://master.php.net/note/reject/79204
Search -- https://master.php.net/manage/user-notes.php