我想捕獲文本「捕獲這個」在$字符串下面。正則表達式捕獲組與PHP preg_match不返回值
$string = "</th><td>Capture This</td>";
$pattern = "/<\/th>\r.*<td>(.*)<\/td>$/";
preg_match ($pattern, $string, $matches);
echo($matches);
但是,那只是返回「數組」。我也嘗試使用print_r打印$匹配,但是這給了我「Array()」。
這種模式只會出現一次,所以我只需要它匹配一次。有人可以告訴我我做錯了什麼嗎?
'有人能告訴我我在做什麼wrong'你試圖用正則表達式來解析HTML。 :) – PeeHaa
https://stackoverflow.com/a/1732454/278739 – Cedric