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? Quote 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 Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.