note 71761 added to function.preg-replace
| From: | alexanderdotkniesaths-bhvdotde at osu1 dot php dot net | Date: | Thu, 14 Dec 2006 17:55:44 +0000 |
| Subject: | note 71761 added to function.preg-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-120611@lists.php.net to get a copy of this message | ||
just one more function to create html-link-tags of out a text-url.
<?php
function find_url($string){
//"www."
$pattern_preg1 = '#(^|\s)(www|WWW)\.([^\s<>\.]+)\.([^\s\n<>]+)#sm';
$replace_preg1 = '\\1<a href="http://\\2.\\3.\\4" target="_blank"
class="link">\\2.\\3.\\4</a>';
//"http://"
$pattern_preg2 =
'#(^|[^\"=\]]{1})(http|HTTP|ftp)(s|S)?://([^\s<>\.]+)\.([^\s<>]+)#sm';
$replace_preg2 = '\\1<a href="\\2\\3://\\4.\\5" target="_blank"
class="link">\\2\\3://\\4.\\5</a>';
$string = preg_replace($pattern_preg1, $replace_preg1, $string);
$string = preg_replace($pattern_preg2, $replace_preg2, $string);
return $string;
}
?>
----
Server IP: 66.163.161.117
Probable Submitter: 84.128.148.218
----
Manual Page -- http://www.php.net/manual/en/function.preg-replace.php
Edit -- https://master.php.net/note/edit/71761
Del: integrated -- https://master.php.net/note/delete/71761/integrated
Del: useless -- https://master.php.net/note/delete/71761/useless
Del: bad code -- https://master.php.net/note/delete/71761/bad+code
Del: spam -- https://master.php.net/note/delete/71761/spam
Del: non-english -- https://master.php.net/note/delete/71761/non-english
Del: in docs -- https://master.php.net/note/delete/71761/in+docs
Del: other reasons-- https://master.php.net/note/delete/71761
Reject -- https://master.php.net/note/reject/71761
Search -- https://master.php.net/manage/user-notes.php