Jump to content

extract text from an anchor


snakebit

Recommended Posts

You can do it with javascript if the link has an id by using this:

 

var anchortext=document.getElementById('thelink').innerHTML;

 

Seeing as this was posted in the regex forum, it's quite unlikely he is seeking a Javascript solution.

 

Could could get it like this:

preg_match('#<a.*>(.*)</a>#iU', $string, $matches);
$text = $matches[1];

 

Link to comment
Share on other sites

:) You're right Daniel0. I didn't notice the forum it was in when I was replying, but it seems he liked the response anyway (though not sure what "10x, perfect" means?! Maybe it should read "100%, perfect". Or maybe he needs a new keyboard!)
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.