Strip anchors down to their contents, only if the anchor's URL contains...

Posted by Tony on Stack Overflow See other posts from Stack Overflow or by Tony
Published on 2010-03-12T07:25:20Z Indexed on 2010/03/12 7:27 UTC
Read the original article Hit count: 257

Filed under:
|
|
|
|

Hi,

Does anyone know a regex function in PHP to strip an anchor of it's contents, only if the anchor's href attribute contains specific text?

For example, I have an HTML page and there are links throughout. But I want to strip only the anchors that contain "yahoo" in the URL. So <a href="http://pages.yahoo.com/page1">Example page</a> would become: Example, while other anchors in the HTML not containing "yahoo" would be left alone.

Thank you in advance. -T

© Stack Overflow or respective owner

Related posts about regex

Related posts about php