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
精彩评论