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 Link to comment https://forums.phpfreaks.com/topic/36710-to-catch-text-of-tags-inside-text/ 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>"; ?> Link to comment https://forums.phpfreaks.com/topic/36710-to-catch-text-of-tags-inside-text/#findComment-175409 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.