我有一個字符串,從一個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