【发布时间】:2012-07-03 09:35:27
【问题描述】:
我正在尝试从标签中提取 src 值, 到目前为止,我似乎能够提取 src 值和字符串中最后一个引号之间的字符串
字符串:
<img border="0" src="http://i.bookfinder.com/about/booksellers/logo_borderless/amazon_uk.gif" width="89" height="31" alt="">
例如在 PHP 中:
preg_match('/src=\"(.*)\"/', $row->find('a img',0), $matches);
if($matches){
echo $matches[0];
}
打印出来
src="http://i.bookfinder.com/about/booksellers/logo_borderless/amazon_uk.gif" width="89" height="31" alt=""
但我真正想要打印的是...
src="http://i.bookfinder.com/about/booksellers/logo_borderless/amazon_uk.gif"
或者如果可能的话……
http://i.bookfinder.com/about/booksellers/logo_borderless/amazon_uk.gif
我应该在正则表达式中添加什么?谢谢
【问题讨论】:
-
在下面查看我的回答,了解您在哪里犯了错误。