0
我试图抓住数值(即105),请检查我的html代码如下...的preg_match问题
<p>
External Backlinks
</p>
<p style="font-size: 150%;">
<b>105</b>
</p>
,我已经使用正则表达式如下...
$url = 'http://www.example.com/test.html';
preg_match('#<p>External Backlinks</p><p style="font-size: 150%;"><b>([0-9\.]+)#', file_get_contents($url), $matches);
echo $matches[1];
但它没有返回正确的值,请帮助修复上述正则表达式。谢谢。
http://stackoverflow.com/a/1732454/1163867 – MarcinJuraszek 2012-02-21 21:32:39
对于HTML,请勿使用* regex *,使用* xpath * 。 Xpath是HTML/XML的“常规”表达式,例如'''p [@ style =“font-size:150%;”]/b'。 – hakre 2012-02-21 22:04:35