PHP 正则获取字符串的URL
程序员文章站
2022-05-06 12:04:59
...
<?php header("charset=utf-8;"); $str ='阅谁问君诵,水落清香浮,http://onestopweb.iteye.com/,一共享共享网站。<img src="http://www.iteye.com/">'; preg_match_all("/http:[\/]{2}[a-z]+[.]{1}[a-z\d\-]+[.]{1}[a-z\d]*[\/]*[A-Za-z\d]*[\/]*[A-Za-z\d]*/",$str,$arr); print_r($arr);
效果图: