2013-03-08 59 views
1

如何查找由<div class="lot-price-block">和由<span关闭的字符' - '分隔的两位数字。preg_match数字序列由字符分隔

我已经尝试这种

preg_match_all('/<div class=\"lot\-price\-block\">(.*?)<span/s',$file_contents,$estimates); 

但它给我的一切不仅是块分隔数字“ - ”

有人有什么想法?

回答

0

尝试是这样的:

$file_contents = '<div class="lot-price-block">fsfd 32424-554 fgdf <span'; 
preg_match_all('/<div class=\"lot-price-block\">\D*(\d+-\d+)\D*<span/s',$file_contents,$estimates); 
echo $estimates[1][0]; 

\ d =>匹配的一切,这不是一个数字([^ 0-9])

\ d =>匹配的一切,这是一个数字([0-9])

PS:你不需要逃避连字符