1
這是我的if語句,將採取從源代碼這個例子HREF:在PHP中使用正則表達式從網址中刪除一個字
href="/toronto/2013/05/14/the-airborne-toxic-event/4296/"
從源代碼
if ($text=preg_match('/href="([^"]*)"/', $text, $matches))
{
$output=$matches[1];
return $output;
}
,並返回
/toronto/2013/05/14/the-airborne-toxic-event/4296/
我想要返回該網址,而不是"/toronto"
或"/toronto/"
(我不確定哪一個我會需要)
如果你能告訴我這樣做的正則表達式,我會非常感激。 感謝
考慮使用'str_replace'而不是正則表達式。這個用例很簡單,它不是真的需要。 – pauljz 2013-05-14 15:23:50