romzer Posted February 1, 2007 Share Posted February 1, 2007 Friends, I am trying to make a regular expression with preg_match_all, that it catches everything that is inside of the < a href="http://www..." > TEXT </a > I would like to catch http://www... and the TEXT. They could help me? My Script: $contents = '<a class=l href="http://www.text.htm"> TESTING </a>'; $regex = "/<a\s(.*)?href=(\"|')[a-zA-Z0-9\/\._-]*\.(\"|')>/i"; preg_match_all($regex, $contents, $matches); echo "<pre>";print_r($matches);echo "</pre>"; Sorry my english. Thanks Quote Link to comment Share on other sites More sharing options...
effigy Posted February 2, 2007 Share Posted February 2, 2007 <?php $contents = '<a class=l href="http://www.text.htm"> TESTING </a>'; $regex = '%<a[^>]+href=(["\'])?([^"\'\s>]+)(?(1)\1)>([^<]+)</a>%i'; preg_match_all($regex, $contents, $matches); echo "<pre>";print_r($matches);echo "</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.