2011-09-23 31 views
0

我有以下搜索一個pregmatch:如何獲取所有的鏈接以http://加

$regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>"; 

現在我該怎麼格式化這個看起來類似:

href="http://plus 

我不希望整個事情被改變,只是該部分的href。

感謝

+4

像往常一樣......不使用正則表達式parseing HTML。你會在某個時候開始自己的腳步。改用DOM和XPath:'// a [starts-with(@ href,'http:// plus')]' –

回答

0

$regexp = "<a\s[^>]*href=(\"??)(http:\/\/plus[^\" >]*?)\\1[^>]*>(.*)<\/a>";