3
我有以下代碼:新手PHP正則表達式問題
<?php
$data="000ffe-fcc9f4 1 000fbe-fccabe";
$pattern='/([0-9A-F]{6})-([0-9A-F]{6})$/i';
echo "the pattern we are using is: ".$pattern."<BR>";
preg_match_all($pattern,$data,$matches, PREG_SET_ORDER);
print_r($matches[0]);
>
我不明白爲什麼它沒有找到這兩個MAC地址作爲匹配?
下面是頁面上的輸出看起來像:
the pattern we are using is: /([0-9A-F]{6})-([0-9A-F]{6})$/i
Array ([0] => 000fbe-fccabe [1] => 000fbe [2] => fccabe)
我期待這個元素[0]將包含兩個000ffe-fcc9f4和000fbe-fccabe。 你能告訴我我做錯了什麼嗎?
謝謝。
doh!非常感謝你。修復它 – dot 2012-08-10 00:56:01
http://ideone.com/GSp1W – 2012-08-10 01:00:51