开发者

How to extract a href value

I would li开发者_如何学Cke 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"/>

Thanks.


You're usually better off parsing it using the likes of simplexml or dom libraries. Using a regex for this is bug-prone.


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

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

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


try this

(?<=href\=\")[\w:\-\=\/\:\d\?\.\#]*

should work

How to extract a href value

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜