Preg_match_all <a href
你好,我想提取链接<a href="/portal/clients/show/entityId/2121" >
我想要一个正则表达式,它给我/portal/clients/show/entityId/2121最后2121的数字在其他链接中不同有什么想法吗?
Hello i want to extract links
<a href="/portal/clients/show/entityId/2121" >
and i want a regex which givs me /portal/clients/show/entityId/2121
the number at last 2121 is in other links different
any idea?
推荐答案
解析链接的正则表达式是这样的:
Regex for parsing links is something like this:
'/<as+(?:[^"'>]+|"[^"]*"|'[^']*')*href=("[^"]+"|'[^']+'|[^<>s]+)/i'
鉴于这有多可怕,我建议至少使用 Simple HTML Dom 来获取链接.然后,您可以在链接 href 上使用一些非常基本的正则表达式来检查链接.
Given how horrible that is, I would recommend using Simple HTML Dom for getting the links at least. You could then check links using some very basic regex on the link href.
相关文章