2011-09-23 32 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>";