Wolphie Posted March 17, 2010 Share Posted March 17, 2010 Okay, so I have this <a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a> which matches all links and returns what I need it to. But how would I go about making it so it only returns the links of a specific class? Link to comment https://forums.phpfreaks.com/topic/195620-regex-for-links-of-a-specific-class/ Share on other sites More sharing options...
JAY6390 Posted March 18, 2010 Share Posted March 18, 2010 You would be better off doing this using the DOM. I have an example on my site: http://www.jaygilford.com/php/php-dom-get-all-pagelinks/ You would just add an if to the foreach to check if $link->getAttribute('class') == 'class_name_here' before adding the link to the array Link to comment https://forums.phpfreaks.com/topic/195620-regex-for-links-of-a-specific-class/#findComment-1027973 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.