Finwyn Posted March 16, 2007 Share Posted March 16, 2007 I want to be able to go though source from a website and grab what is between all the <li></li> and <a href="lalala"></a> . I am new to regex and was wondering if its possible to do this with it? Quote Link to comment Share on other sites More sharing options...
effigy Posted March 16, 2007 Share Posted March 16, 2007 Does it need to work recursively, e.g., finding a's in li's? <pre> <?php $html = <<<HTML ... <a href="http://www.phpfreaks.com">www.phpfreaks.com</a> <ul> <li>Item 1</li> <li>Item 2</li> <li><a href="#Item_3">Item 3</a></li> </ul> ... HTML; preg_match_all('%<(a|li).*?>(.+?)</\1>%', $html, $matches); print_r($matches); ?> </pre> 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.