0
已经有几篇关于查找文本链接的文章,但是没有一篇完全适用于我的案例。 这一个是更接近我:使用正则表达式查找链接到文本
$reg_exUrl = "#(https?|ftp)://\S+[^\s.,>)\];'\"!?]#";
preg_match_all($reg_exUrl, $content, $result);
这几乎适用于除下列内容的所有情况:
$content = '<p><br></p><p>https://www.google.com <br></p><p>http://localhost/index.php?view=model <br></p><p><br></p><p>http://localhost/index.php?view=scheduler/ <br></p><p><br></p><p>http://localhost/index.php?view=module<br></p><p><br></p><p><br></p>';
如果链接后面没有空格则preg_match_all取HTML将链接作为链接的一部分
如何修改正则表达式以便在存在HTML标记时停止?