我有一个字符串,从一个file_get_contents()函数调用,包含如下:提取使用的preg_match价格在PHP
<span class="cb_price_countdown cb_lot_price_1439066">$40.65</span>
而且我想提取物价格40.65。我不熟悉正则表达式或preg_match,所以我很难。到目前为止,我曾尝试:
$pattern = "/\\\$?((\d{1,3}(,\d{3})*)|(\d+))(\.\d{2})?$/";
preg_match ($pattern, $subject, $matches);
print_r ($matches);
这是不返回任何有用,我已经试过:
,但它是相同的故事。有人能告诉我正在寻找正确的preg_match模式吗?
谢谢
贾斯汀
不使用正则表达式这一点。不要从其他网站窃取内容。 – 2013-02-17 19:34:13
[不要使用正则表达式解析HTML](http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454) – 2013-02-17 19:34:36
我应该怎么做使用? – JuJoDi 2013-02-17 19:34:40