如何提取href值 [英] How to extract a href value

查看:67
本文介绍了如何提取href值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想提取 href 值(没有任何库),我该怎么做?

I would like to extract the href value (without any library), how can I do it?

<dm:link rel="uql" href="URL-URL-URL-URL" type="application/rss+xml"/>

谢谢.

推荐答案

虽然可以说 DOM 解析器是最好的解决方案,但使用正则表达式可以相当可靠地完成这项小任务.

Though arguably a DOM parser would be the best solution, this small task could be done quite reliably with a regex.

此外,如果使用库,您还需要导入 dm 命名空间的信息.

Also, you'd need to import the info for the dm namespace if using a library.

preg_match('/\shref="(?<href>[^"]+)"/', $str, $match);

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

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