Jump to content

To catch text of tags inside <a href="">text</a>


romzer

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.