Preg_match_all lt;a href(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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Preg_match_all <a href
基础教程推荐
- 如何替换eregi() 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
