正则表达式问题 <a class="pdf" href="http://www.feedbooks.com/book/4384.pdf">PDF</a>如何匹配出此链接中的href后面的连接地址 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 $str = '<a class="pdf" href="http://www.feedbooks.com/book/4384.pdf">PDF</a>';if(preg_match('|<a class="pdf" href="(.*?)">PDF</a>|ims',$str,$match)){ print_r($match[1]);} $s = '<a class="pdf" href="http://www.feedbooks.com/book/4384.pdf">PDF</a>';preg_match("/<a[^<>]*href=\"([^\"]+)\"[^<>]*>/i", $s, $matches);echo $matches[1]; 问题补充: 刚才忘了说了,要求匹配的是在一个网页中找到该标签中的href链接地址 $str='<a class="pdf" href="http://www.feedbooks.com/book/4384.pdf">PDF</a>'; preg_match_all('/<a\s.*class=\"pdf\" href=\"(.*)\"/i',$str,$match); print_r($match) 没有干扰的话应该没问题$str='<a class="pdf" href="http://www.feedbooks.com/book/4384.pdf">PDF</a>';preg_match_all('/<a class="pdf" href="([^"]+)"/i',$str,$matches);print_r($matches[1]); 求高手解决:HTML更新时候,出现“DedeTag Engine Create File False”的问题,怎么解决? discuz登录菜单 thinkphp 数组问题 求助 在thinkphp的官方例子中file上传的图片保存不到Upload里 php中小问题,大家来看看吧 imagecolorallocate 分配失败 ubuntu php占用大量资源 微信自带的浏览怎么才可以记住密码 字符串里面的内容如何替换成数组的内容? php 连表查询 curl上传文件到远程服务器的问题 安裝magento遇到mysql的問題
$str = '<a class="pdf" href="http://www.feedbooks.com/book/4384.pdf">PDF</a>';if(preg_match('|<a class="pdf" href="(.*?)">PDF</a>|ims',$str,$match)){
print_r($match[1]);
}
$s = '<a class="pdf" href="http://www.feedbooks.com/book/4384.pdf">PDF</a>';
preg_match("/<a[^<>]*href=\"([^\"]+)\"[^<>]*>/i", $s, $matches);
echo $matches[1];
preg_match_all('/<a\s.*class=\"pdf\" href=\"(.*)\"/i',$str,$match);
print_r($match)
preg_match_all('/<a class="pdf" href="([^"]+)"/i',$str,$matches);
print_r($matches[1]);