php 匹配正则 取出url
原创
©著作权归作者所有:来自51CTO博客作者mp624183768的原创作品,请联系作者获取转载授权,否则将追究法律责任
取出所有url 并且不要重复
function getJustAllUrl($inUrlText)
{
$parttern = "/http[s]?:\/\/(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+/";
preg_match_all($parttern, $inUrlText, $match);
return count($match) > 0 ? array_unique($match[0]) : '';
}
取出仅仅url
function getJustUrl($inUrlText)
{
$parttern = "/http[s]?:\/\/(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+/";
preg_match($parttern, $inUrlText, $match);
return count($match) > 0 ? $match[0] : '';
}