roman1290 Posted August 3, 2010 Share Posted August 3, 2010 Hello dear experts, I'm having trouble using pre_match to select the location of an icon from HTML: <link rel="apple-touch-icon" href="http://www.website.com/icon.png" type="image/png" /> and I would like to store this string: http://www.website.com/icon.png So far I've been trying use: /(<link rel="apple-touch-icon" href="(.*)" \/>)/i but it selects: http://www.website.com/icon.png" type="image/png I would like to select just the URL. I know this must be simple, but I'm new to regular expressions, and search results have not been able to help me thus far, and I desperately need to get this to work. Thank you in advance. Quote Link to comment https://forums.phpfreaks.com/topic/209718-preg_match-grab-url/ Share on other sites More sharing options...
newbtophp Posted August 4, 2010 Share Posted August 4, 2010 Change the (.*) to (.*?) to make it ungreedy. Quote Link to comment https://forums.phpfreaks.com/topic/209718-preg_match-grab-url/#findComment-1094901 Share on other sites More sharing options...
roman1290 Posted August 4, 2010 Author Share Posted August 4, 2010 Thank you very much, I changed it to: /(<link rel="apple-touch-icon" href="(.*?)")/i and it works every time. Quote Link to comment https://forums.phpfreaks.com/topic/209718-preg_match-grab-url/#findComment-1094914 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.