我想在链接尚未在链接中的字符串中查找 URL
我当前的代码:
$text = "http://www.google.com is a great website. Visit <a href='http://www.google.com' >http://google.com</a>"
$reg_exUrl = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/";
if(preg_match($reg_exUrl, $text, $url)) {
$links = preg_replace($reg_exUrl, '<a href="'.$url[0].'" rel="nofollow">'.$url[0].'</a>', $_page['content']['external_links']);
}
Run Code Online (Sandbox Code Playgroud)
问题在于它返回了两次链接(这就是它返回的内容):
<a href="http://www.google.com" rel="nofollow">http://www.google.com</a> is a great website. Visit <a href='<a href="http://www.google.com" rel="nofollow">http://www.google.com</a>' ><a href="http://www.google.com" rel="nofollow">http://www.google.com</a></a>
Run Code Online (Sandbox Code Playgroud) 如何通过数据划线设置范围.
例如.在我的HTML中有:
<span data-scribe="element:verified_badge">?</span>
Run Code Online (Sandbox Code Playgroud)
我怎样才能在这个特定范围内添加CSS样式?