-4
$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"

这是我拥有的字符串。我需要做的是将两个网址转换为链接到页面的链接,然后将电子邮件转换为 mailto: 链接。

我不需要考虑 blahblah.com 的网站。他们将永远拥有这些 www 之一。或 http(s)。我对正则表达式很糟糕......所以我们将不胜感激!

4

1 回答 1

0
$output = preg_replace('_<a href="(?!mailto:)(?!tel:)[^"]+[^>]*>(.+?)</a>_', '$1', $string1);
echo '<pre>'.print_r(htmlentities($output), true).'</pre>';
于 2013-10-04T14:45:44.507 回答