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 Link to comment https://forums.phpfreaks.com/topic/207858-preg_match-help/ 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' Link to comment https://forums.phpfreaks.com/topic/207858-preg_match-help/#findComment-1086646 Share on other sites More sharing options...
runthis Posted July 15, 2010 Author Share Posted July 15, 2010 Parse error: syntax error, unexpected '{' Link to comment https://forums.phpfreaks.com/topic/207858-preg_match-help/#findComment-1086647 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 Link to comment https://forums.phpfreaks.com/topic/207858-preg_match-help/#findComment-1087211 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.