runthis Posted July 15, 2010 Share Posted July 15, 2010 Im not new to php at all, but havent had the need to use preg_match I want to get all the links off of a page, but i want the href, not the class or title or anything heres what i have to get the links <a\s[^>]*href=(\"??)(\/stuff[^\" >]*?)\\1[^>]*>(.*)<\/a> that matches any link that starts with /stuff Quote Link to comment Share on other sites More sharing options...
ZachMEdwards Posted July 15, 2010 Share Posted July 15, 2010 Would this work? '%<a.+href="{0,1}(/stuff[^">]+)%s' Quote Link to comment Share on other sites More sharing options...
runthis Posted July 15, 2010 Author Share Posted July 15, 2010 Parse error: syntax error, unexpected '{' Quote Link to comment Share on other sites More sharing options...
ZachMEdwards Posted July 16, 2010 Share Posted July 16, 2010 Try this: preg_match_all('%<a.+href="{0,1}(/stuff[^">]+)%s', $html, $matches); print_r($matches); Where $html is your text Quote Link to comment 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.