Preg_match_all <a href [英] Preg_match_all &lt;a href

查看:27
本文介绍了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.

这篇关于Preg_match_all <a href的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆