PHP将URL转换为字符串中的链接

PHP将URL转换为字符串中的链接,php,regex,Php,Regex,这是我的绳子。我需要做的是将两个URL转换为链接到一个页面的链接,然后将电子邮件转换为mailto:links 我不需要对blahblah.com网站进行说明。他们将始终拥有其中一个www.或http(s)。我对正则表达式很糟糕。。。因此,我们将感谢您的帮助 $output=preg_replace(“uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu; $string1 = "You can view the full

这是我的绳子。我需要做的是将两个URL转换为链接到一个页面的链接,然后将电子邮件转换为mailto:links

我不需要对blahblah.com网站进行说明。他们将始终拥有其中一个www.或http(s)。我对正则表达式很糟糕。。。因此,我们将感谢您的帮助

$output=preg_replace(“uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu;
$string1 = "You can view the full calendar at 
           http://www.something.org/calendar/57682117 
           or email: info@something.org"
$string2 = "You can view the full calendar at 
           www.something.org/calendar/57682117 
           or email: info@something.org"
回显“”。打印(htmlentities($output),true)。“”;
这些都没有提到如何只搜索一个简单的www或http站点。此外,对m.site.com和其他网站的“重复”搜索。。。和我要找的不相关…那不行。我只是测试了它,但根据我提供的示例,它不会产生任何链接或任何东西。
$output = preg_replace('_<a href="(?!mailto:)(?!tel:)[^"]+[^>]*>(.+?)</a>_', '$1', $string1);
echo '<pre>'.print_r(htmlentities($output), true).'</pre>';