本文介绍了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/2121the number at last 2121 is in other links differentany idea?
推荐答案
解析链接的正则表达式是这样的:
Regex for parsing links is something like this:
'/<a\s+(?:[^"'>]+|"[^"]*"|'[^']*')*href=("[^"]+"|'[^']+'|[^<>\s]+)/i'
考虑到多么可怕是的,我建议至少使用来获取链接。然后你可以使用一些链接查看链接链接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.
这篇关于Preg_match_all< a href的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!